Skill Tracer
Skills › Scientific Agent Skills › database-lookup › openweathermap.md

openweathermap.md

267 lines · skills/database-lookup/references/openweathermap.md at 5f2bc03

Open on GitHub
1# OpenWeatherMap API Reference
2

OpenWeatherMap API Reference

Raw lines 1 to 2
3## Base URL
4```
5https://api.openweathermap.org
6```
7

Base URL

https://api.openweathermap.org
Raw lines 3 to 7
8## Authentication
9- **API Key: REQUIRED.** Register for a free key at https://home.openweathermap.org/users/sign_up
10- Pass as query parameter: `&appid=YOUR_KEY`
11- Free tier key activates within a few hours of registration.

Authentication

  • API Key: REQUIRED. Register for a free key at https://home.openweathermap.org/users/sign_up
  • Pass as query parameter: &appid=YOUR_KEY
  • Free tier key activates within a few hours of registration.
Raw lines 8 to 12
13## Rate Limits (Free Tier)
14- Quotas depend on product and subscription; check the account and [pricing page](https://openweathermap.org/price) before a batch.
15- **Current weather, 5-day forecast, geocoding:** Available on free tier.
16- **One Call 3.0:** Requires subscription (1,000 free calls/day with credit card on file).
17- **Air pollution history** is documented from 2020-11-27; weather-history subscriptions are a separate product. Do not assume all history routes have the same entitlement.
19---

Rate Limits (Free Tier)

  • Quotas depend on product and subscription; check the account and pricing page before a batch.
  • Current weather, 5-day forecast, geocoding: Available on free tier.
  • One Call 3.0: Requires subscription (1,000 free calls/day with credit card on file).
  • Air pollution history is documented from 2020-11-27; weather-history subscriptions are a separate product. Do not assume all history routes have the same entitlement.

Raw lines 13 to 20
21## Key Endpoints

Key Endpoints

Raw lines 21 to 22
23### 1. Current Weather
24```
25GET /data/2.5/weather
26```
28**Parameters:**
29| Parameter | Type | Required | Default | Description |
30|-----------|--------|----------|----------|-------------|
31| `q` | string | Cond. | - | City name, optionally with state/country: `London`, `London,GB`, `Portland,OR,US`. |
32| `lat` | float | Cond. | - | Latitude (use with `lon`). |
33| `lon` | float | Cond. | - | Longitude (use with `lat`). |
34| `id` | int | Cond. | - | City ID (from OWM city list). |
35| `zip` | string | Cond. | - | Zip/postal code with country: `90210,US`, `SW1,GB`. |
36| `units` | string | No | `standard` | `standard` (Kelvin), `metric` (Celsius), `imperial` (Fahrenheit). |
37| `lang` | string | No | `en` | Language code for descriptions. |
38| `appid` | string | Yes | - | API key. |
40Use `lat`+`lon`. Built-in city-name, city-ID and ZIP geocoding (`q`, `id`, `zip`) is deprecated although still available; resolve locations through `/geo/1.0/` for maintained integrations.
42**Example:**
43```
44https://api.openweathermap.org/data/2.5/weather?lat=40.7128&lon=-74.0060&units=metric&appid=YOUR_KEY
45```
47**Response:**
48```json
50 "coord": {"lon": -74.006, "lat": 40.7128},
51 "weather": [
52 {
53 "id": 800,
54 "main": "Clear",
55 "description": "clear sky",
56 "icon": "01d"
57 }
58 ],
59 "base": "stations",
60 "main": {
61 "temp": 22.5,
62 "feels_like": 21.8,
63 "temp_min": 20.1,
64 "temp_max": 24.3,
65 "pressure": 1013,
66 "humidity": 55,
67 "sea_level": 1013,
68 "grnd_level": 1010
69 },
70 "visibility": 10000,
71 "wind": {"speed": 3.6, "deg": 220, "gust": 5.1},
72 "clouds": {"all": 0},
73 "dt": 1700000000,
74 "sys": {
75 "country": "US",
76 "sunrise": 1699960000,
77 "sunset": 1699996000
78 },
79 "timezone": -18000,
80 "id": 5128581,
81 "name": "New York",
82 "cod": 200
84```

1. Current Weather

GET /data/2.5/weather

Parameters:

ParameterTypeRequiredDefaultDescription
qstringCond.-City name, optionally with state/country: London, London,GB, Portland,OR,US.
latfloatCond.-Latitude (use with lon).
lonfloatCond.-Longitude (use with lat).
idintCond.-City ID (from OWM city list).
zipstringCond.-Zip/postal code with country: 90210,US, SW1,GB.
unitsstringNostandardstandard (Kelvin), metric (Celsius), imperial (Fahrenheit).
langstringNoenLanguage code for descriptions.
appidstringYes-API key.

Use lat+lon. Built-in city-name, city-ID and ZIP geocoding (q, id, zip) is deprecated although still available; resolve locations through /geo/1.0/ for maintained integrations.

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
}
Raw lines 23 to 85
86### 2. 5-Day / 3-Hour Forecast (Free)
87```
88GET /data/2.5/forecast
89```
90Returns forecast data in 3-hour intervals for 5 days (40 data points). Same location parameters as current weather.
92**Additional Parameters:**
93| Parameter | Type | Description |
94|-----------|------|-------------|
95| `cnt` | int | Number of 3-hour steps to return (max 40). |
97**Example:**
98```
99https://api.openweathermap.org/data/2.5/forecast?lat=51.5085&lon=-0.1257&units=metric&cnt=8&appid=YOUR_KEY
100```
102**Response:**
103```json
105 "cod": "200",
106 "message": 0,
107 "cnt": 8,
108 "list": [
109 {
110 "dt": 1700000000,
111 "main": {
112 "temp": 10.5,
113 "feels_like": 8.2,
114 "temp_min": 9.8,
115 "temp_max": 10.5,
116 "pressure": 1020,
117 "humidity": 80
118 },
119 "weather": [{"id": 802, "main": "Clouds", "description": "scattered clouds", "icon": "03d"}],
120 "clouds": {"all": 40},
121 "wind": {"speed": 4.1, "deg": 250},
122 "visibility": 10000,
123 "pop": 0.2,
124 "dt_txt": "2024-01-15 12:00:00"
125 }
126 ],
127 "city": {
128 "id": 2643743,
129 "name": "London",
130 "coord": {"lat": 51.5085, "lon": -0.1257},
131 "country": "GB",
132 "population": 1000000,
133 "timezone": 0,
134 "sunrise": 1699950000,
135 "sunset": 1699982000
136 }
138```
139`pop` is probability of precipitation (0.0 to 1.0).

2. 5-Day / 3-Hour Forecast (Free)

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:

ParameterTypeDescription
cntintNumber of 3-hour steps to return (max 40).

Example:

https://api.openweathermap.org/data/2.5/forecast?lat=51.5085&lon=-0.1257&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).

Raw lines 86 to 140
141### 3. Geocoding
142```
143GET /geo/1.0/direct
144GET /geo/1.0/reverse
145GET /geo/1.0/zip
146```
148**Direct geocoding (city name to coordinates):**
149```
150https://api.openweathermap.org/geo/1.0/direct?q=London,GB&limit=5&appid=YOUR_KEY
151```
152Returns array of `{name, lat, lon, country, state}`.
154**Reverse geocoding (coordinates to city name):**
155```
156https://api.openweathermap.org/geo/1.0/reverse?lat=51.5085&lon=-0.1257&limit=1&appid=YOUR_KEY
157```
159**Zip code geocoding:**
160```
161https://api.openweathermap.org/geo/1.0/zip?zip=90210,US&appid=YOUR_KEY
162```

3. Geocoding

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
Raw lines 141 to 163
164### 4. One Call API 3.0 (Subscription Required)
165```
166GET /data/3.0/onecall
167```
168Comprehensive endpoint returning current, minutely (1h), hourly (48h), daily (8d), and alerts in one call.
170**Parameters:**
171| Parameter | Type | Required | Description |
172|-----------|--------|----------|-------------|
173| `lat` | float | Yes | Latitude. |
174| `lon` | float | Yes | Longitude. |
175| `exclude` | string | No | Comma-separated parts to exclude: `current`, `minutely`, `hourly`, `daily`, `alerts`. |
176| `units` | string | No | `standard`, `metric`, `imperial`. |
177| `appid` | string | Yes | API key. |
179**Example:**
180```
181https://api.openweathermap.org/data/3.0/onecall?lat=40.7128&lon=-74.006&exclude=minutely,alerts&units=metric&appid=YOUR_KEY
182```

4. One Call API 3.0 (Subscription Required)

GET /data/3.0/onecall

Comprehensive endpoint returning current, minutely (1h), hourly (48h), daily (8d), and alerts in one call.

Parameters:

ParameterTypeRequiredDescription
latfloatYesLatitude.
lonfloatYesLongitude.
excludestringNoComma-separated parts to exclude: current, minutely, hourly, daily, alerts.
unitsstringNostandard, metric, imperial.
appidstringYesAPI key.

Example:

https://api.openweathermap.org/data/3.0/onecall?lat=40.7128&lon=-74.006&exclude=minutely,alerts&units=metric&appid=YOUR_KEY
Raw lines 164 to 183
184### 5. One Call API 4.0 (separate subscription)
186The current [One Call 4.0 documentation](https://openweathermap.org/api/one-call-4) describes a separate endpoint family; the 3.0 route above remains separately documented. Do not change only the version in a 3.0 URL.
188```text
189GET /data/4.0/onecall/current?lat={lat}&lon={lon}&appid={key}
190GET /data/4.0/onecall/timeline/1h?lat={lat}&lon={lon}&appid={key}
191GET /data/4.0/onecall/timeline/1day?lat={lat}&lon={lon}&appid={key}
192```
194Responses contain location/timezone fields and a `data` array. Timeline responses can include `next`/`prev` URLs; follow those URLs rather than constructing offsets. Each page is a billed API call under the selected plan. The One Call by Call plan includes 1,000 calls/day free, while the initial account cap is 2,000 calls/day; those are different thresholds. Check the configured limit before running a batch. Examples here are documentation-verified, not authenticated live tests.

5. One Call API 4.0 (separate subscription)

The current One Call 4.0 documentation describes a separate endpoint family; the 3.0 route above remains separately documented. Do not change only the version in a 3.0 URL.

GET /data/4.0/onecall/current?lat={lat}&lon={lon}&appid={key}
GET /data/4.0/onecall/timeline/1h?lat={lat}&lon={lon}&appid={key}
GET /data/4.0/onecall/timeline/1day?lat={lat}&lon={lon}&appid={key}

Responses contain location/timezone fields and a data array. Timeline responses can include next/prev URLs; follow those URLs rather than constructing offsets. Each page is a billed API call under the selected plan. The One Call by Call plan includes 1,000 calls/day free, while the initial account cap is 2,000 calls/day; those are different thresholds. Check the configured limit before running a batch. Examples here are documentation-verified, not authenticated live tests.

Raw lines 184 to 195
196### 6. Air Pollution
197```
198GET /data/2.5/air_pollution
199GET /data/2.5/air_pollution/forecast
200GET /data/2.5/air_pollution/history
201```
203**Parameters:** `lat`, `lon`, `appid` (required). For history: `start` and `end` (Unix timestamps).
205**Example:**
206```
207https://api.openweathermap.org/data/2.5/air_pollution?lat=40.7128&lon=-74.006&appid=YOUR_KEY
208```
210**Response:**
211```json
213 "coord": {"lon": -74.006, "lat": 40.7128},
214 "list": [
215 {
216 "main": {"aqi": 2},
217 "components": {
218 "co": 230.31,
219 "no": 0.5,
220 "no2": 15.0,
221 "o3": 68.0,
222 "so2": 2.5,
223 "pm2_5": 8.1,
224 "pm10": 12.3,
225 "nh3": 1.0
226 },
227 "dt": 1700000000
228 }
229 ]
231```
232AQI scale: 1=Good, 2=Fair, 3=Moderate, 4=Poor, 5=Very Poor. Components in ug/m3.
234---

6. Air Pollution

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.


Raw lines 196 to 235
236## Weather Condition Codes
237| Range | Category |
238|---------|----------|
239| 2xx | Thunderstorm |
240| 3xx | Drizzle |
241| 5xx | Rain |
242| 6xx | Snow |
243| 7xx | Atmosphere (fog, mist, haze) |
244| 800 | Clear |
245| 80x | Clouds |
247Weather icons: `https://openweathermap.org/img/wn/{icon}@2x.png`

Weather Condition Codes

RangeCategory
2xxThunderstorm
3xxDrizzle
5xxRain
6xxSnow
7xxAtmosphere (fog, mist, haze)
800Clear
80xClouds

Weather icons: https://openweathermap.org/img/wn/{icon}@2x.png

Raw lines 236 to 248
249## Free Tier vs Paid Summary
250| Endpoint | Free | Subscription |
251|----------|------|-------------|
252| Current weather | Yes | Yes |
253| 5-day/3-hour forecast | Yes | Yes |
254| Geocoding | Yes | Yes |
255| Air pollution (current) | Yes | Yes |
256| One Call 3.0 | 1000/day (credit card required) | Yes |
257| Historical weather | No | Yes |
258| Daily forecast 16-day | No | Yes |
259| Climatic forecast 30-day | No | Yes |

Free Tier vs Paid Summary

EndpointFreeSubscription
Current weatherYesYes
5-day/3-hour forecastYesYes
GeocodingYesYes
Air pollution (current)YesYes
One Call 3.01000/day (credit card required)Yes
Historical weatherNoYes
Daily forecast 16-dayNoYes
Climatic forecast 30-dayNoYes
Raw lines 249 to 260
261## Notes
262- All timestamps (`dt`, `sunrise`, `sunset`) are **Unix epoch seconds (UTC)**.
263- `timezone` field is offset in seconds from UTC (e.g. -18000 = UTC-5).
264- Default temperature unit is Kelvin. Always specify `units=metric` or `units=imperial`.
265- City name queries (`q=`) can be ambiguous. Prefer `lat`+`lon` for precision, using geocoding first if needed.
266- Weather icon URL pattern: `https://openweathermap.org/img/wn/{icon}@2x.png` (e.g. `01d` for clear day).
267- Error responses return `{"cod": 401, "message": "Invalid API key"}` or similar.

Notes

  • All timestamps (dt, sunrise, sunset) are Unix epoch seconds (UTC).
  • timezone field is offset in seconds from UTC (e.g. -18000 = UTC-5).
  • Default temperature unit is Kelvin. Always specify units=metric or units=imperial.
  • City name queries (q=) can be ambiguous. Prefer lat+lon for precision, using geocoding first if needed.
  • Weather icon URL pattern: https://openweathermap.org/img/wn/{icon}@2x.png (e.g. 01d for clear day).
  • Error responses return {"cod": 401, "message": "Invalid API key"} or similar.
Raw lines 261 to 267