Back
Indian API

Indian API

How to Use the Indian Weather API

Weather API Documentation

Introduction

Welcome to the Weather API, your go-to solution for accurate and up-to-date weather information. This API provides comprehensive weather data from two primary sources:

  1. Indian Meteorological Department (IMD) for Indian cities
  2. Aggregated global weather data from various providers

Whether you're building a weather app, integrating weather information into your website, or conducting climate research, our API has you covered with real-time data and forecasts.

API Key

To use the Weather API, you'll need an API key. Good news! You can get started for free:

  • Subscribe for free and receive 1000 requests
  • Visit http://indianapi.in/weather-api to get your API key
  • For higher request volumes, paid plans are available

Base URL

The base URL for all API requests is:

https://weather.indianapi.in

Authentication

Include your API key in the header of each request:

x-api-key: YOUR_API_KEY_HERE

API Sandbox

To test the API without using your request quota, use our sandbox environment:

http://indianapi.in/sandbox/weather-api

Endpoints

1. Get Indian Cities

Retrieve a list of all available Indian cities and their IMD station IDs.

Endpoint: /india/cities Method: GET

Example Request:

curl -H "x-api-key: YOUR_API_KEY_HERE" https://weather.indianapi.in/india/cities

Example Response:

{
  "53": "Kanpur airforce",
  "8205": "Chamba",
  "10001": "Faridabad",
  "10002": "Bhadrak (ranital)",
  // ... more cities
}

2. Get India City Weather

Get detailed weather information for an Indian city.

Endpoint: /india/weather Method: GET

Parameters:

  • city (required): Name of the Indian city (fuzzy matching is applied)

Example Request:

curl -H "x-api-key: YOUR_API_KEY_HERE" https://weather.indianapi.in/india/weather?city=Chennai

Example Response:

{
  "city": "Chennai-meenambakkam",
  "weather": {
    "current": {
      "humidity": {
        "evening": 64,
        "morning": 71
      },
      "rainfall": null,
      "temperature": {
        "max": {
          "value": 32.1,
          "departure": -2.3
        },
        "min": {
          "value": 26.5,
          "departure": 1
        }
      }
    },
    "forecast": [
      {
        "date": "08-Sep-2024",
        "max_temp": 32,
        "min_temp": 27,
        "description": "Generally cloudy sky with moderate rain"
      },
      // ... 6 more days of forecast
    ],
    "astronomical": {
      "sunset": "18:15",
      "moonset": "21:31",
      "sunrise": "05:58",
      "moonrise": "09:48"
    }
  }
}

3. Get Global Current Weather

Retrieve current weather conditions for any location worldwide.

Endpoint: /global/current Method: GET

Parameters:

  • location (required): City name, airport code, or latitude,longitude

Example Request:

curl -H "x-api-key: YOUR_API_KEY_HERE" https://weather.indianapi.in/global/current?location=New York

Example Response:

{
  "temperature": 22.5,
  "feels_like": 23.1,
  "humidity": 65,
  "wind_speed": 5.2,
  "wind_direction": "NE",
  "condition": "Partly cloudy",
  "uv_index": 4
}

4. Get Global Weather

Get current weather and forecast for a specific location globally.

Endpoint: /global/weather Method: GET

Parameters:

  • location (required): City name, airport code, or latitude,longitude
  • days (optional): Number of forecast days (1-3, default is 3)

Example Request:

curl -H "x-api-key: YOUR_API_KEY_HERE" https://weather.indianapi.in/global/weather?location=London&days=2

Example Response:

{
  "location": "London, UK",
  "current": {
    "temperature": 18.5,
    "feels_like": 17.9,
    "humidity": 72,
    "wind_speed": 4.1,
    "wind_direction": "SW",
    "condition": "Overcast",
    "uv_index": 2
  },
  "forecast": [
    {
      "date": "2024-09-25",
      "max_temp": 20.1,
      "min_temp": 15.3,
      "sunrise": "06:45",
      "sunset": "19:15",
      "moonrise": "14:30",
      "moonset": "23:45",
      "moon_phase": "Waxing Gibbous",
      "hourly": [
        {
          "time": "00:00",
          "temperature": 16.2,
          "feels_like": 15.8,
          "humidity": 78,
          "wind_speed": 3.5,
          "wind_direction": "SW",
          "condition": "Partly cloudy",
          "chance_of_rain": 10
        },
        // ... more hourly forecasts
      ]
    },
    // ... one more day of forecast
  ]
}

5. Get Global Forecast

Retrieve a detailed weather forecast for a specific location globally.

Endpoint: /global/forecast Method: GET

Parameters:

  • location (required): City name, airport code, or latitude,longitude
  • days (optional): Number of forecast days (1-3, default is 3)

Example Request:

curl -H "x-api-key: YOUR_API_KEY_HERE" https://weather.indianapi.in/global/forecast?location=Paris&days=3

Example Response:

[
  {
    "date": "2024-09-25",
    "max_temp": 24.5,
    "min_temp": 18.2,
    "sunrise": "07:15",
    "sunset": "19:45",
    "moonrise": "15:20",
    "moonset": "01:30",
    "moon_phase": "First Quarter",
    "hourly": [
      {
        "time": "00:00",
        "temperature": 19.5,
        "feels_like": 19.2,
        "humidity": 70,
        "wind_speed": 2.8,
        "wind_direction": "E",
        "condition": "Clear",
        "chance_of_rain": 0
      },
      // ... more hourly forecasts
    ]
  },
  // ... two more days of forecast
]

6. Get India City Weather By ID

Retrieve detailed weather information for an Indian city using its IMD ID.

Endpoint: /india/weather_by_id Method: GET

Parameters:

  • city_id (required): IMD station ID for the city

Example Request:

curl -H "x-api-key: YOUR_API_KEY_HERE" https://weather.indianapi.in/india/weather_by_id?city_id=43555

Example Response:

{
  "city": "Chennai-nungambakkam",
  "weather": {
    "current": {
      "humidity": {
        "evening": 81,
        "morning": 76
      },
      "rainfall": null,
      "temperature": {
        "max": {
          "value": 32.8,
          "departure": -1.5
        },
        "min": {
          "value": 27.6,
          "departure": 1.7
        }
      }
    },
    "forecast": [
      {
        "date": "08-Sep-2024",
        "max_temp": 33,
        "min_temp": 28,
        "description": "Generally cloudy sky with moderate rain"
      },
      // ... 6 more days of forecast
    ],
    "astronomical": {
      "sunset": "18:15",
      "moonset": "21:30",
      "sunrise": "05:58",
      "moonrise": "09:47"
    }
  }
}

Error Handling

The API uses standard HTTP response codes to indicate the success or failure of requests. Here are some common codes you might encounter:

  • 200: Successful request
  • 404: City or location not found
  • 422: Validation error (check your parameters)
  • 500: Internal server error

In case of an error, you'll receive a JSON response with more details about the error.

Rate Limiting

Free accounts are limited to 1000 requests. For higher volumes, please check our paid plans at http://indianapi.in/weather-api.

Conclusion

This Weather API provides a robust set of endpoints to access accurate and up-to-date weather information for both Indian cities and global locations. Whether you're building a weather app, a travel planner, or integrating weather data into your existing application, this API offers the flexibility and data you need.

Remember to keep your API key secure and never expose it in client-side code. If you have any questions or need further assistance, please don't hesitate to contact our support team.

Happy coding, and may your applications be as sunny as the weather forecasts they display!