NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server

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
(4.7)

From 6,675 users

700+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
281ms315ms370ms524ms1154ms

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 and lon
  • city, state (optional), and country (optional)
  • lat  optional

    Latitude of desired location.

  • lon  optional

    Longitude of desired location.

  • zip  optional premium

    5 digit Zip code (United States only)

  • city  optional 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

A JSON object with the following fields or an error if the request is unsuccessful.

  • 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
city premium
state premium
country premium

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.1278

Headers

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

Sample Response

JSON
{
    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

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!

lat
lon

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.1278

Headers

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

Sample Response

JSON
[
    {
      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
    },
    "..."
]

Frequently Asked Questions

  • 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.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • 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.
  • 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.
  • The /v1/weather endpoint accepts either lat and lon coordinates, or a city name with optional state (US only) and country parameters; note that the city, state, country, and zip parameters 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.
  • All temperature fields (temp, feels_like, min_temp, max_temp) are returned in Celsius, wind_speed is in meters per second, and wind_degrees gives wind direction in degrees, while humidity and cloud_pct are percentages. For other location-based data sources, see our full API catalog.
  • Yes, the /v1/weather response includes sunrise and sunset times, both given as Unix timestamps. To convert these to a location's local time, you can combine the response with our Timezone API.
  • The /v1/weatherforecast endpoint 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 as temp, humidity, and wind_speed); on the free tier it requires lat and lon. If a request returns an error instead, check our error codes reference.