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.

Available endpoints:

  • /v1/weather - Get current weather data by city, ZIP code, or geolocation coordinates
  • /v1/weatherforecast - Get a 5-day weather forecast in 3-hour intervals

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
295ms320ms373ms500ms961ms

Didn't find what you were looking for? Suggest an improvement

/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

One of the following parameter combinations must be provided:

  • lat  required

    Latitude of desired location.

  • lon  required

    Longitude of desired location.

  • zip  required premium

    5 digit Zip code (United States only)

  • 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 Live Demo!

lat
lon
https://api.api-ninjas.com/v1/weather?lat=51.5074&lon=-0.1278

Headers

X-Api-KeyLog in or sign up to get your API Key

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

One of the following parameter combinations must be provided:

  • lat  required

    Latitude of desired location.

  • lon  required

    Longitude of desired location.

  • zip  required premium

    5 digit Zip code (United States only)

  • 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 Forecast Request Live Demo!

lat
lon
https://api.api-ninjas.com/v1/weatherforecast?lat=51.5074&lon=-0.1278

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [ { "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 }, "..." ]