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
From 6,675 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 281ms | 315ms | 370ms | 524ms | 1154ms |
Similar APIs
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:
latandloncity,state(optional), andcountry(optional)
latoptionalLatitude of desired location.
lonoptionalLongitude of desired location.
zipoptional premium5 digit Zip code (United States only)
cityoptional premiumCity name.
stateoptional premiumUS state (for United States cities only).
countryoptional premiumCountry name.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON object with the following fields or an error if the request is unsuccessful.
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!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
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
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
A JSON array of objects with the same fields as Weather Response, or an error if the request is unsuccessful.
Sample Forecast Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
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
Frequently Asked Questions
Can I use the Weather API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Weather API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Weather API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Weather API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.How do I query weather by city name versus coordinates?
The/v1/weatherendpoint accepts eitherlatandloncoordinates, or acityname with optionalstate(US only) andcountryparameters; note that thecity,state,country, andzipparameters are premium-only, as shown on our pricing page. If you only have a place name and need coordinates first, pair it with our Geocoding API.What units does the Weather API return for temperature and wind?
All temperature fields (temp,feels_like,min_temp,max_temp) are returned in Celsius,wind_speedis in meters per second, andwind_degreesgives wind direction in degrees, whilehumidityandcloud_pctare percentages. For other location-based data sources, see our full API catalog.Are sunrise and sunset times included, and what format are they in?
Yes, the/v1/weatherresponse includessunriseandsunsettimes, both given as Unix timestamps. To convert these to a location's local time, you can combine the response with our Timezone API.How far ahead does the weather forecast endpoint go?
The/v1/weatherforecastendpoint returns a 5-day forecast in 3-hour intervals as a JSON array, with each entry containing the same fields as the current weather response (such astemp,humidity, andwind_speed); on the free tier it requireslatandlon. If a request returns an error instead, check our error codes reference.