weather.com.cn APIweather.com.cn ↗
Access real-time weather, 7–40 day forecasts, AQI rankings, hourly observations, and active alerts for any Chinese city via the weather.com.cn API.
curl -X GET 'https://api.parse.bot/scraper/91fc294e-bc9f-47ba-b48e-d6ab94bebab7/search_city_weather?query=%E4%B8%8A%E6%B5%B7' \ -H 'X-API-Key: $PARSE_API_KEY'
Search for a city by name to find its city code. Returns matching cities, districts, and scenic spots. Use the returned city_code in other endpoints.
| Param | Type | Description |
|---|---|---|
| queryrequired | string | City name to search for, in Chinese characters or pinyin (e.g. '北京', 'shanghai'). |
{
"type": "object",
"fields": {
"results": "array of city objects each containing city_code, pinyin, city_name, en_name, district, province, full_info"
},
"sample": {
"data": {
"results": [
{
"pinyin": "shanghai",
"en_name": "Shanghai",
"district": "上海",
"province": "上海",
"city_code": "101020100",
"city_name": "上海",
"full_info": "101020100~shanghai~上海~Shanghai~上海~Shanghai~21~200000~SH~上海"
}
]
},
"status": "success"
}
}About the weather.com.cn API
The weather.com.cn API provides 8 endpoints covering real-time conditions, multi-range forecasts (7-day, 15-day, 40-day), hourly observations, air quality rankings, and nationwide weather alerts for cities across China. Start with search_city_weather to resolve a city name or pinyin string into the 9-digit city code required by every other endpoint, then pull station-level temperature, humidity, wind, and AQI alongside daily life indices like UV, comfort, and clothing recommendations.
City Resolution and Real-Time Conditions
Every data request in this API is keyed on a 9-digit city_code. Use search_city_weather with a Chinese-character name or pinyin string (e.g. '北京' or 'shanghai') to get back matching cities, districts, and scenic spots, each with city_code, pinyin, city_name, en_name, district, and province fields. Once you have a code, get_current_weather returns five response objects: dataSK (real-time station observations: temp, humidity, wind, AQI), dataZS (daily life indices: comfort, UV, clothing, travel), cityDZ (today's brief forecast and any active alarm info), fc (short-range daily forecast array), and sk_detailed (extended station data).
Forecast Ranges
get_forecast_7day returns a 5–7 day array where each object carries fa (day weather code), fb (night weather code), fc (high temp), fd (low temp), and wind fields. get_forecast_15day extends this to 15 days and adds sunrise/sunset times and lunar calendar dates encoded under numeric keys (001 for day weather code, 003/004 for high/low temps, 009 for date in YYYYMMDD format). get_forecast_40day produces a calendar array covering up to 40 days and includes historical average highs/lows (hmax/hmin), lunar day (nl), almanac data (nlyf), and both observed and forecast temperatures — useful for agricultural or travel planning tools that need longer-horizon context.
Hourly Observations and Air Quality
get_hourly_observations returns up to 24 hours of station records under observations_24h.od.od2, with per-hour fields od21 (hour), od22 (temp), od23 (wind speed), od24 (wind direction), and AQI. get_air_quality requires no inputs and returns national AQI rankings split into four arrays: af (best air quality cities), ab (worst), p10 (ranked by PM10), and p25 (ranked by PM2.5). Each entry includes a (city_code), n (name), p (province), and v (AQI value). get_weather_alerts also requires no inputs and returns all currently active nationwide alerts as an array of entries with location name, alert ID, and longitude, plus a count field.
Coverage Scope
All endpoints are scoped to mainland China cities, districts, and scenic spots indexed by weather.com.cn. The city search covers Chinese-character input and pinyin, but results are limited to locations that weather.com.cn tracks — smaller townships or newly established administrative areas may not appear. The 40-day forecast includes historical baselines alongside forward projections, making it distinct from the 7-day and 15-day endpoints which carry only forecast data.
- Display real-time temperature, humidity, and AQI for a Chinese city in a travel or logistics dashboard using
get_current_weather. - Build a clothing or activity recommendation feature using the
dataZSlife indices (UV, comfort, clothing) returned byget_current_weather. - Render a 15-day forecast calendar with lunar dates and sunrise/sunset times for a Chinese-market calendar app via
get_forecast_15day. - Plot a 40-day temperature range chart against historical averages using
hmax/hminfields fromget_forecast_40day. - Monitor nationwide air quality trends by polling
get_air_qualityfor ranked PM2.5 and PM10 city lists. - Surface active weather alerts on a map by parsing the location and coordinates returned by
get_weather_alerts. - Back-fill a 24-hour temperature and wind time series for a city using the
od2hourly records fromget_hourly_observations.
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 250 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.
Does weather.com.cn have an official developer API?+
How do I look up the city code for a specific location?+
search_city_weather accepts a query parameter in either Chinese characters or pinyin and returns an array of matching cities, districts, and scenic spots. Each result includes a city_code (9-digit string) that is the required input for all other endpoints. For example, querying '北京' returns Beijing's code 101010100.What does the 40-day forecast endpoint actually include versus the 7-day and 15-day endpoints?+
get_forecast_40day is a calendar-style view: each day entry combines historical average high/low (hmax/hmin), lunar calendar information (nl, nlyf), almanac data, and forecast or observed temperatures. The 7-day and 15-day endpoints focus on day/night weather codes, actual forecast temperatures, and wind data without the historical baseline or lunar fields. The 40-day endpoint also accepts an optional month parameter to fetch a specific month's calendar.Does the API cover weather data for Taiwan, Hong Kong, or Macau?+
Does `get_weather_alerts` let me filter alerts by province or city?+
get_weather_alerts returns all active nationwide alerts in a single response; there is no input parameter to filter by region, severity, or alert type. The response includes a location name and alert ID per entry that you can filter client-side. You can fork this API on Parse and revise it to add a filtered alerts endpoint that accepts a province or city code.