scientific-skills/database-lookup/references/openweathermap.md
https://api.openweathermap.org
&appid=YOUR_KEYGET /data/2.5/weather
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
q | string | Cond. | - | City name, optionally with state/country: London, London,GB, Portland,OR,US. |
lat | float | Cond. | - | Latitude (use with lon). |
lon | float | Cond. | - | Longitude (use with lat). |
id | int | Cond. | - | City ID (from OWM city list). |
zip | string | Cond. | - | Zip/postal code with country: 90210,US, SW1,GB. |
units | string | No | standard | standard (Kelvin), metric (Celsius), imperial (Fahrenheit). |
lang | string | No | en | Language code for descriptions. |
appid | string | Yes | - | API key. |
One location parameter (q, lat+lon, id, or zip) is required.
Example:
https://api.openweathermap.org/data/2.5/weather?lat=40.7128&lon=-74.0060&units=metric&appid=YOUR_KEY
Response:
{
"coord": {"lon": -74.006, "lat": 40.7128},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01d"
}
],
"base": "stations",
"main": {
"temp": 22.5,
"feels_like": 21.8,
"temp_min": 20.1,
"temp_max": 24.3,
"pressure": 1013,
"humidity": 55,
"sea_level": 1013,
"grnd_level": 1010
},
"visibility": 10000,
"wind": {"speed": 3.6, "deg": 220, "gust": 5.1},
"clouds": {"all": 0},
"dt": 1700000000,
"sys": {
"country": "US",
"sunrise": 1699960000,
"sunset": 1699996000
},
"timezone": -18000,
"id": 5128581,
"name": "New York",
"cod": 200
}
GET /data/2.5/forecast
Returns forecast data in 3-hour intervals for 5 days (40 data points). Same location parameters as current weather.
Additional Parameters:
| Parameter | Type | Description |
|---|---|---|
cnt | int | Number of 3-hour steps to return (max 40). |
Example:
https://api.openweathermap.org/data/2.5/forecast?q=London,GB&units=metric&cnt=8&appid=YOUR_KEY
Response:
{
"cod": "200",
"message": 0,
"cnt": 8,
"list": [
{
"dt": 1700000000,
"main": {
"temp": 10.5,
"feels_like": 8.2,
"temp_min": 9.8,
"temp_max": 10.5,
"pressure": 1020,
"humidity": 80
},
"weather": [{"id": 802, "main": "Clouds", "description": "scattered clouds", "icon": "03d"}],
"clouds": {"all": 40},
"wind": {"speed": 4.1, "deg": 250},
"visibility": 10000,
"pop": 0.2,
"dt_txt": "2024-01-15 12:00:00"
}
],
"city": {
"id": 2643743,
"name": "London",
"coord": {"lat": 51.5085, "lon": -0.1257},
"country": "GB",
"population": 1000000,
"timezone": 0,
"sunrise": 1699950000,
"sunset": 1699982000
}
}
pop is probability of precipitation (0.0 to 1.0).
GET /geo/1.0/direct
GET /geo/1.0/reverse
GET /geo/1.0/zip
Direct geocoding (city name to coordinates):
https://api.openweathermap.org/geo/1.0/direct?q=London,GB&limit=5&appid=YOUR_KEY
Returns array of {name, lat, lon, country, state}.
Reverse geocoding (coordinates to city name):
https://api.openweathermap.org/geo/1.0/reverse?lat=51.5085&lon=-0.1257&limit=1&appid=YOUR_KEY
Zip code geocoding:
https://api.openweathermap.org/geo/1.0/zip?zip=90210,US&appid=YOUR_KEY
GET /data/3.0/onecall
Comprehensive endpoint returning current, minutely (1h), hourly (48h), daily (8d), and alerts in one call.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
lat | float | Yes | Latitude. |
lon | float | Yes | Longitude. |
exclude | string | No | Comma-separated parts to exclude: current, minutely, hourly, daily, alerts. |
units | string | No | standard, metric, imperial. |
appid | string | Yes | API key. |
Example:
https://api.openweathermap.org/data/3.0/onecall?lat=40.7128&lon=-74.006&exclude=minutely,alerts&units=metric&appid=YOUR_KEY
GET /data/2.5/air_pollution
GET /data/2.5/air_pollution/forecast
GET /data/2.5/air_pollution/history
Parameters: lat, lon, appid (required). For history: start and end (Unix timestamps).
Example:
https://api.openweathermap.org/data/2.5/air_pollution?lat=40.7128&lon=-74.006&appid=YOUR_KEY
Response:
{
"coord": {"lon": -74.006, "lat": 40.7128},
"list": [
{
"main": {"aqi": 2},
"components": {
"co": 230.31,
"no": 0.5,
"no2": 15.0,
"o3": 68.0,
"so2": 2.5,
"pm2_5": 8.1,
"pm10": 12.3,
"nh3": 1.0
},
"dt": 1700000000
}
]
}
AQI scale: 1=Good, 2=Fair, 3=Moderate, 4=Poor, 5=Very Poor. Components in ug/m3.
| Range | Category |
|---|---|
| 2xx | Thunderstorm |
| 3xx | Drizzle |
| 5xx | Rain |
| 6xx | Snow |
| 7xx | Atmosphere (fog, mist, haze) |
| 800 | Clear |
| 80x | Clouds |
Weather icons: https://openweathermap.org/img/wn/{icon}@2x.png
| Endpoint | Free | Subscription |
|---|---|---|
| Current weather | Yes | Yes |
| 5-day/3-hour forecast | Yes | Yes |
| Geocoding | Yes | Yes |
| Air pollution (current) | Yes | Yes |
| One Call 3.0 | 1000/day (credit card required) | Yes |
| Historical weather | No | Yes |
| Daily forecast 16-day | No | Yes |
| Climatic forecast 30-day | No | Yes |
dt, sunrise, sunset) are Unix epoch seconds (UTC).timezone field is offset in seconds from UTC (e.g. -18000 = UTC-5).units=metric or units=imperial.q=) can be ambiguous. Prefer lat+lon for precision, using geocoding first if needed.https://openweathermap.org/img/wn/{icon}@2x.png (e.g. 01d for clear day).{"cod": 401, "message": "Invalid API key"} or similar.