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
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 295ms | 320ms | 373ms | 500ms | 961ms |
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:
latrequiredLatitude of desired location.
lonrequiredLongitude of desired location.
ziprequired premium5 digit Zip code (United States only)
cityrequired premiumCity name.
stateoptional premiumUS state (for United States cities only).
countryoptional premiumCountry name.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
tempCurrent temperature in Celsius.
feels_likeWhat the temperature feels like in Celsius.
humidityCurrent humidity percentage.
min_tempMinimum temperature in Celsius.
max_tempMaximum temperature in Celsius.
wind_speedWind speed in meters per second.
wind_degreesWind direction in degrees.
sunriseSunrise time in Unix timestamp.
sunsetSunset time in Unix timestamp.
Sample Request Live Demo!
https://api.api-ninjas.com/v1/weather?lat=51.5074&lon=-0.1278Headers
X-Api-KeyLog in or sign up to get your API KeySample Response
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:
latrequiredLatitude of desired location.
lonrequiredLongitude of desired location.
ziprequired premium5 digit Zip code (United States only)
cityrequired premiumCity name.
stateoptional premiumUS state (for United States cities only).
countryoptional premiumCountry name.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
Returns a list of weather forecasts with the same fields as Weather Response.
Sample Forecast Request Live Demo!
https://api.api-ninjas.com/v1/weatherforecast?lat=51.5074&lon=-0.1278Headers
X-Api-KeyLog in or sign up to get your API KeySample Response
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
},
"..."
]