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
- /v1/weathericons - Get the complete weather icon catalog (Premium only)
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
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 Premium only5 digit Zip code (United States only)
cityoptional Premium onlyCity name.
stateoptional Premium onlyUS state (for United States cities only).
countryoptional Premium onlyCountry 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.
cloud_pctCloud cover 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.
weatherPrimary weather category, such as Rain, Snow, or Clouds; null if unavailable.
weather_codeDetailed provider condition ID. Unknown IDs are preserved; null if no valid ID is available.
weather_descriptionDescription of the primary condition. Use this as the icon alternative text.
is_dayWhether it is daytime at the weather location. True for day, false for night, or null when unavailable. This is independent of your application theme.
weather_iconStable icon name, such as rain-light or clear-night. Unknown conditions use the unknown icon.
weather_icon_urlPublic HTTPS URL of the SVG icon for a light interface.
weather_icon_url_darkPublic HTTPS URL of the SVG icon for a dark interface.
weather_icon_png_urlPublic HTTPS URL of the 128-pixel transparent PNG for a light interface.
weather_icon_png_url_darkPublic HTTPS URL of the 128-pixel transparent PNG for a dark interface.
weather_conditionsAll simultaneous conditions, in provider order. Each has the weather, weather_code, weather_description, is_day, weather_icon, and four URL fields above. The first is the primary condition. An empty array means condition data was unavailable.
Live Demo
Code Examples
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.
https://api.api-ninjas.com/v1/weatherforecast
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 Premium only5 digit Zip code (United States only)
cityrequired Premium onlyCity name.
stateoptional Premium onlyUS state (for United States cities only).
countryoptional Premium onlyCountry 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.
Live Demo
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/weatherforecast?lat=51.5074&lon=-0.1278" \
-H "X-Api-Key: YOUR_API_KEY"Premium only
https://api.api-ninjas.com/v1/weathericons
Returns the complete weather icon catalog: 74 icon names, 592 public image URLs, and mappings for all 55 supported condition codes. Every icon includes light and dark SVGs and transparent PNGs at 64, 128, and 256 pixels.
This endpoint requires a Premium subscription. The individual icon URLs in current weather and forecast responses remain available with those endpoints.
Parameters
This endpoint does not require any parameters.
Headers
X-Api-Key (required): an API key associated with a paid subscription. Anonymous demo access is not available.
Response
A JSON object with the following fields, or an error if authentication, subscription, or quota checks fail.
versionVersion of the icon collection.
icon_countNumber of distinct icon names (74), each available in both themes.
file_countTotal number of image URLs across both themes and all formats (592).
condition_countNumber of mapped provider condition codes (55).
iconsComplete list of icons. Each entry includes icon (stable name), description, weather_codes, phase, type, light, and dark. Each theme contains svg and png URLs; png is keyed by 64, 128, and 256.
conditionsComplete condition mapping. Each entry contains code, description, and icons, which maps day, night, and neutral to stable icon names.
phase is day, night, neutral (time unspecified), or any (the same icon at all times). type is core, extension, or fallback. Extension and fallback icons have an empty weather_codes array; extensions do not imply that the API currently detects those phenomena.
Choose the theme to match your interface and the phase to match the weather location. Preserve the condition description alongside the icon, especially at small sizes.
Live Demo
Get a free API key to get started — no credit card required.
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/weathericons" \
-H "X-Api-Key: YOUR_API_KEY"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.Does the Weather API include icons for light and dark mode?
Yes. Current weather and forecast responses includeweather_icon_urlandweather_icon_url_darkfor SVG icons, plusweather_icon_png_urlandweather_icon_png_url_darkfor transparent 128-pixel PNGs. The Premium-only/v1/weathericonsendpoint returns all 592 image URLs across 74 icon names, both themes, and every available size, with mappings for all 55 supported condition codes.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.
Explore API integration use cases for recommended APIs and workflow examples.