Save over 30% when you subscribe to an annual subscription plan!

Weather API

The Weather API provides the latest weather, forecast, and historical weather data for any city or geographic location in the world.

/v1/weather GET

https://api.api-ninjas.com/v1/weather

Get current weather, wind speed and direction, humidity, and temperature data by city, ZIP code, or geolocation coordinates (latitude/longitude).


Parameters

  • lat  required

    Latitude of desired location.

  • lon  required

    Longitude of desired location.

  • — or —
  • zip  required premium

    5 digit Zip code (United States only)

  • — or —
  • city  required premium

    City name.

  • state  optional premium

    US state (for United States cities only).

  • country  optional premium

    Country name.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

  • temp

    Current temperature in Celsius.

  • feels_like

    What the temperature feels like in Celsius.

  • humidity

    Current humidity percentage.

  • min_temp

    Minimum temperature in Celsius.

  • max_temp

    Maximum temperature in Celsius.

  • wind_speed

    Wind speed in meters per second.

  • wind_degrees

    Wind direction in degrees.

  • sunrise

    Sunrise time in Unix timestamp.

  • sunset

    Sunset time in Unix timestamp.

Sample Request

https://api.api-ninjas.com/v1/weather?city=London

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 { "wind_speed": 5.66, "wind_degrees": 210, "temp": 7, "humidity": 87, "sunset": 1615658463, "min_temp": 7, "cloud_pct": 75, "feels_like": 2, "sunrise": 1615616341, "max_temp": 8 }

Code Examples

1 2 curl -X GET "https://api.api-ninjas.com/v1/weather?city=london" \ -H "X-Api-Key: YOUR_API_KEY"

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.

/v1/weatherforecast GET

https://api.api-ninjas.com/v1/weather

Returns a 5-day weather forecast in 3-hour intervals for a given city.


Parameters

  • lat  required

    Latitude of desired location.

  • lon  required

    Longitude of desired location.

  • — or —
  • zip  required premium

    5 digit Zip code (United States only)

  • — or —
  • city  required premium

    City name.

  • state  optional premium

    US state (for United States cities only).

  • country  optional premium

    Country name.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

Returns a list of weather forecasts with the same fields as Weather Response.

Sample Request

https://api.api-ninjas.com/v1/weatherforecast?city=London

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [ { "timestamp": 1740247200, "temp": 13, "feels_like": 12, "humidity": 70, "min_temp": 10, "max_temp": 13, "weather": "Clouds", "cloud_pct": 40, "wind_speed": 2.36, "wind_degrees": 231 }, { "timestamp": 1740258000, "temp": 11, "feels_like": 11, "humidity": 76, "min_temp": 9, "max_temp": 11, "weather": "Clouds", "cloud_pct": 27, "wind_speed": 2.3, "wind_degrees": 231 }, "..." ]