APIYard
Back to APIs
WeatherAPI KeyFree tier

OpenWeatherMap

Access weather data for any location — current conditions, 5-day forecasts, historical data, and UV index for 200,000+ cities.

Base URL

https://api.openweathermap.org/data/2.5
forecastcurrenthistoricalUVglobal

Endpoints

GET/weather

Get current weather data for a city.

const response = await fetch("https://api.openweathermap.org/data/2.5/weather?q=London&units=metric&appid=YOUR_API_KEY", {
  method: "GET",
  headers: {
  "Content-Type": "application/json",
  "X-API-Key": "YOUR_API_KEY"
  }
});

const data = await response.json();
console.log(data);

Response Preview

{
  "name": "London",
  "main": {
    "temp": 14.2,
    "feels_like": 13.1,
    "humidity": 72
  },
  "weather": [{ "main": "Clouds", "description": "overcast clouds" }],
  "wind": { "speed": 4.1 }
}
GET/forecast

Get a 5-day / 3-hour step forecast.

const response = await fetch("https://api.openweathermap.org/data/2.5/forecast?q=London&units=metric&appid=YOUR_API_KEY", {
  method: "GET",
  headers: {
  "Content-Type": "application/json",
  "X-API-Key": "YOUR_API_KEY"
  }
});

const data = await response.json();
console.log(data);

Response Preview

{
  "list": [
    { "dt": 1718100000, "main": { "temp": 14.2 }, "weather": [{ "main": "Rain" }] },
    { "dt": 1718110800, "main": { "temp": 13.8 }, "weather": [{ "main": "Clouds" }] }
  ],
  "city": { "name": "London" }
}