Skip to content

Weather Alerts

Alert Independent API

We recommend the independent v3 Alert API; alerts in v2 are in maintenance mode and will not gain new features.

Weather alert data: add the alert=true parameter to any weather data endpoint (Realtime, Minutely, Hourly, Daily, Combined) to get the currently active alerts for the requested location in result.alert.

Alert information is synchronized with the Central Meteorological Bureau and is returned by matching the requested coordinates to administrative divisions (province/city/district levels); grid spatial resolution does not apply. Province-level alerts of non-municipality provinces are not returned; when a lower-level division has issued an alert of the same type (same first 2 digits of the type code), the upper-level alert of that type is not returned. For details, see Variable Coverage.

Request

GET https://api.caiyunapp.com/v2.6/{token}/{longitude},{latitude}/{endpoint}?alert=true

{endpoint} is one of realtime, minutely, hourly, daily, weather.

Path Parameters

ParameterDescription
tokenAPI token; the token must have alert permission for the response to include result.alert
longitudeLongitude of the target location
latitudeLatitude of the target location

Note: in the URL path, longitude comes first, latitude second (e.g. 116.3176,39.9760); the location field in the response is in [latitude, longitude] order.

Query Parameters

NameRequiredDefaultRangeDescription
alertNofalsetrue/falseOnly with alert=true and an alert-enabled token does the response include result.alert
langNozh_CNzh_CN/zh_TW/en_US/en_GB/jaLanguage of natural-language descriptions; falls back to zh_CN when unmatched. See Languages
unitNometricmetric/metric:v1/metric:v2/SI/imperialUnit system; any other value returns 422. See Units
callbackNo--JSONP callback name

Step parameters specific to each endpoint (e.g. dailysteps, hourlysteps) are documented on the corresponding endpoint pages.

Request Example

bash
curl "https://api.caiyunapp.com/v2.6/TAkhjf8d1nlSlspN/116.3176,39.9760/realtime?alert=true"
json
{
  "status": "ok",
  "api_version": "v2.6",
  "api_status": "active",
  "lang": "zh_CN",
  "unit": "metric",
  "tzshift": 28800,
  "timezone": "Asia/Shanghai",
  "server_time": 1640759880,
  "location": [39.976, 116.3176],
  "result": {
    "alert": {
      "status": "ok",
      "content": [
        {
          "province": "Beijing",
          "status": "alerting",
          "code": "0501",
          "description": "Haidian District Meteorological Observatory issued a blue gale alert at 07:25 on the 29th. From now until 16:00 on the 29th, Haidian District will see northerly winds of force 3-4, with gusts of force 6-7. Please take precautions.",
          "regionId": "101010200",
          "county": "none",
          "pubtimestamp": 1640733900,
          "latlon": [39.959912, 116.298056],
          "city": "Haidian District",
          "alertId": "11010841600000_20211229072633",
          "title": "Haidian District Meteorological Observatory issued a blue gale alert [IV/General]",
          "adcode": "110108",
          "source": "National Early Warning Information Release Center",
          "location": "Haidian District, Beijing",
          "request_status": "ok"
        }
      ],
      "adcodes": [
        {
          "adcode": 110000,
          "name": "Beijing"
        },
        {
          "adcode": 110108,
          "name": "Haidian District"
        }
      ]
    },
    "realtime": {
      //
    },
    "primary": 0
  }
}

Response Fields

JSONPath $.result.alert.Description
statusStatus of the alert data block
content[].provinceProvince, e.g. "Fujian Province"
content[].cityCity, e.g. "Sanming"
content[].countyCounty, e.g. "none"
content[].statusAlert status, always "alerting"(预警中)
content[].code4-digit alert code: first 2 digits are the type, last 2 digits are the level, e.g. "0902"
content[].descriptionOriginal alert description text
content[].regionIdRegion ID, e.g. "101010200"
content[].pubtimestampPublish time, unix seconds, e.g. 1587443583
content[].latlonLocation of the issuing agency, [latitude, longitude]
content[].alertIdAlert ID, e.g. "35040041600001_20200421123203"
content[].titleAlert title, e.g. "Sanming Meteorological Observatory issued a yellow thunderstorm alert [III/Relatively Severe]"
content[].adcodeAdministrative division code, e.g. "350400"
content[].sourceIssuing source, e.g. "National Early Warning Information Release Center"
content[].locationPlace, e.g. "Sanming, Fujian Province"
content[].request_statusRequest status, always "ok"
adcodesAdministrative divisions of the requested location, [{adcode, name}]; always returned (even when there are no alerts)

Notes:

  • The expire_time field is not returned.
  • When there are no alerts, result.alert is {"status": "ok", "content": [], "adcodes": [...]}.
  • When the alert upstream fails, content is [] and adcodes is null.

Encoding Rules

The alert code is taken from the code field: the first two digits of the alert code are the alert type, and the last two digits are the alert level. For example, "code": "0901" decomposes into the structure alert type code + alert level code, giving a blue thunderstorm alert.

Alert Type Codes

Alert TypeType Code
Typhoon(台风)01
Rainstorm(暴雨)02
Snowstorm(暴雪)03
Cold Wave(寒潮)04
Gale(大风)05
Sandstorm(沙尘暴)06
Heat Wave(高温)07
Drought(干旱)08
Thunderstorm(雷电)09
Hail(冰雹)10
Frost(霜冻)11
Fog(大雾)12
Haze(霾)13
Road Icing(道路结冰)14
Forest Fire Risk(森林火险)15
Thunderstorm Gale(雷雨大风)16
Spring Sand & Dust Weather Trend Alert(春季沙尘天气趋势预警)17
Sand & Dust(沙尘)18

Alert Level Codes

Alert LevelLevel Code
White(白色)00
Blue(蓝色)01
Yellow(黄色)02
Orange(橙色)03
Red(红色)04

Errors

Error responses have the following structure. See Error Messages for HTTP status codes and their meanings.

{
  "status": "failed",
  "error": "token is invalid",
  "api_version": "2.6"
}