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
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
https://api.api-ninjas.com/v1/weather?city=LondonSample 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
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 Request
https://api.api-ninjas.com/v1/weatherforecast?city=LondonSample Response
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
},
"..."
]