Back to Session 4

Web APIs Guide

Learn to interact with real-world APIs using command line tools

📮 Post Office API

The Post Office API allows you to fetch detailed information about any location in India using its PIN code. This includes the post office name, district, state, and more.

1.1 Open Ubuntu VM
Launch your Ubuntu virtual machine and open the terminal. Make sure you have an active internet connection.
💡 Prerequisites:
  • Ubuntu VM must be running
  • Terminal application opened
  • Internet connection active
  • curl command should be available (pre-installed on most Ubuntu systems)
1.2 Use the Post Office API
Copy and run the following command to fetch postal information. Replace with your desired PIN code.
Command Format
curl https://api.postalpincode.in/pincode/
Example Usage:
Bash
curl https://api.postalpincode.in/pincode/530016
✅ Expected Output:
  • JSON response containing post office details
  • Information includes: Name, Branch Type, Delivery Status, Circle, District, Division, Region, State
  • You'll see data for all post offices associated with that PIN code
  • Status field will indicate if the PIN code is valid
💡 Try different PIN codes:
  • Mumbai: 400001
  • Delhi: 110001
  • Bangalore: 560001
  • Chennai: 600001
  • Visakhapatnam: 530016

🌤️ Weather API

The wttr.in Weather API provides current weather information for any city in the world. It displays beautifully formatted weather data directly in your terminal.

2.1 Open Ubuntu VM
Launch your Ubuntu virtual machine and open the terminal. Ensure you have internet connectivity to fetch live weather data.
💡 Prerequisites:
  • Ubuntu VM must be running
  • Terminal application opened
  • Active internet connection
  • curl command available
2.2 Use the Weather API
Copy and run the following command to get weather information. Replace with your desired city.
Command Format
curl wttr.in/
Example Usage:
Bash
curl wttr.in/Visakhapatnam
✅ What you'll see:
  • Beautiful ASCII art weather display
  • Current temperature and "feels like" temperature
  • Weather conditions (sunny, cloudy, rainy, etc.)
  • Wind speed and direction
  • Visibility and humidity levels
  • 3-day weather forecast
  • Sunrise and sunset times
💡 Try different cities:
  • Mumbai: curl wttr.in/Mumbai
  • London: curl wttr.in/London
  • New York: curl wttr.in/NewYork
  • Tokyo: curl wttr.in/Tokyo
  • Paris: curl wttr.in/Paris
⚠️ Advanced Options:
  • Specific format: Add ?format=3 for compact output
    curl wttr.in/Visakhapatnam?format=3
  • Different units: Add ?m for metric or ?u for US units
  • Moon phase: Try curl wttr.in/Moon
  • PNG image: Add .png at the end to get an image