Skip to content

Location API

Access Restriction

This API is a premium service available only to enterprise tier developers. Please contact Caiyun Sales to purchase.

TIP

CAP weather alerts are currently supported for the United States. Other countries and regions are being added gradually.

Each request consumes one API call quota.

Request:

bash
curl "https://singer.caiyunhub.com/v3/cap_alert/location?token={token}&longitude=-118.25&latitude=34.05&language=en-US"

Request parameters:

FieldTypeRequiredDescription
longitudefloatYesLongitude
latitudefloatYesLatitude
languagestringNoResponse text language, defaults to zh-CN

Response

json
{
  "alerts": [
    {
      "id": "nws-alert-1",
      "region_code": "US",
      "source": 1,
      "msg_type": 1,
      "event_name": "Flash Flood Warning",
      "categories": [2],
      "urgency": 1,
      "severity": 2,
      "certainty": 2,
      "sent_time": 1750123200,
      "effective_time": 1750123200,
      "onset_time": 1750125000,
      "expires_time": 1750130400,
      "references": [],
      "areas": [
        {
          "area_desc": "Los Angeles",
          "geocodes": [
            {
              "value_name": "UGC",
              "value": "CAC037",
              "namespace": "NWS_UGC"
            }
          ],
          "polygons": [
            {
              "vertices": [
                { "latitude": 34.11, "longitude": -118.45 },
                { "latitude": 34.10, "longitude": -118.10 },
                { "latitude": 33.90, "longitude": -118.12 }
              ]
            }
          ],
          "circles": [
            {
              "center": { "latitude": 34.05, "longitude": -118.25 },
              "radius_km": 10
            }
          ]
        }
      ],
      "language_code": "en-US",
      "sender_name": "NWS Los Angeles/Oxnard CA",
      "headline": "Flash Flood Warning issued for Los Angeles",
      "description": "Flash flooding caused by excessive rainfall is expected.",
      "instruction": "Move to higher ground immediately."
    }
  ]
}

CAPAlerts

FieldTypeDescription
alertsCAPAlert[]CAP weather alert records

CAPAlert

FieldTypeDescription
idstringUnique alert identifier. Do not parse it for business logic.
region_codestringISO 3166-1 Alpha-2 code
sourceint32Alert source. See CAPAlertSource
msg_typeint32CAP msgType. See CAPAlertMsgType
event_namestringEvent name, preferring the selected response language
categoriesint32[]CAP info.category. Currently only the Met type is returned. See CAPAlertCategory
urgencyint32CAP info.urgency. See CAPAlertUrgency
severityint32CAP info.severity. See CAPAlertSeverity
certaintyint32CAP info.certainty. See CAPAlertCertainty
sent_timeint64Sent timestamp in seconds
effective_timeint64Effective timestamp in seconds
onset_timeint64Onset timestamp in seconds
expires_timeint64Expiration timestamp in seconds
referencesstring[]CAP references
areasCAPAlertArea[]Affected areas
language_codestringLanguage code of the returned text
sender_namestringSender name
headlinestringHeadline
descriptionstringAlert description
instructionstringRecommended instructions

CAPAlertArea

FieldTypeDescription
area_descstringArea description
geocodesCAPAlertGeocode[]Area geocodes
polygonsCAPAlertPolygon[]Polygon geometries
circlesCAPAlertCircle[]Circle geometries
altitudedoubleCAP altitude, in meters
ceilingdoubleCAP ceiling, in meters

CAPAlertGeocode

FieldTypeDescription
value_namestringGeocode name
valuestringGeocode value
namespacestringGeocode namespace

CAPAlertPolygon

FieldTypeDescription
verticesLatLng[]Polygon vertices with latitude/longitude fields

CAPAlertCircle

FieldTypeDescription
centerLatLngCircle center with latitude/longitude fields
radius_kmdoubleRadius in kilometers

CAPAlertSource

New enum values may be added at any time. Code should handle unknown values.

NumberDescription
1US National Weather Service
2Environment and Climate Change Canada

CAPAlertMsgType

NumberDescription
1Alert
2Update
3Cancel

CAPAlertCategory

NumberDescription
1Geo
2Met
3Safety
4Security
5Rescue
6Fire
7Health
8Env
9Transport
10Infra
11CBRNE
12Other

CAPAlertUrgency

NumberDescription
1Immediate
2Expected
3Future
4Past
5Unknown

CAPAlertSeverity

NumberDescription
1Extreme
2Severe
3Moderate
4Minor
5Unknown

CAPAlertCertainty

NumberDescription
1Observed
2Likely
3Possible
4Unlikely
5Unknown