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 and Canada. Other countries and regions are being added gradually.

Each request consumes one API call quota.

Request

http
GET https://singer.caiyunhub.com/v3/cap_alert/location

Query Parameters

NameRequiredDefaultRangeDescription
tokenYesAPI token; see Authentication
longitudeYesLongitude
latitudeYesLatitude
languageNozh-CNBCP 47 language tagResponse text language. Current data provides en-US, en-CA, and fr-CA; if the requested language is unavailable, the first language provided by the source is returned.

Request Example

United States:

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

Canada (French):

bash
curl "https://singer.caiyunhub.com/v3/cap_alert/location?token={token}&longitude=-73.5673&latitude=45.5017&language=fr-CA"

Response Example

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."
    }
  ],
  "attributions": [
    {
      "source": 1,
      "provider": "National Weather Service (NWS)",
      "source_url": "https://api.weather.gov/alerts/active.atom",
      "attribution_text": "Source: National Weather Service (NWS).",
      "license_id": "public-domain",
      "license_url": "https://www.weather.gov/disclaimer",
      "applies_to": "alert_data"
    }
  ]
}

Response Fields

CAPAlerts

JSONPathTypeDescription
$.alertsarray<CAPAlert>CAP weather alert records
$.attributionsarray<CAPAlertAttribution>Data source, license, and attribution metadata

CAPAlertAttribution

FieldTypeDescription
sourcenumberAlert source. See CAPAlertSource
providerstringProvider of the alert data or geometry
source_urlstringSource URL
attribution_textstringAttribution text intended for display
license_idstringLicense identifier
license_urlstringLicense URL; omitted when unavailable
terms_urlstringSource terms-of-use URL; omitted when unavailable
applies_tostringAttribution scope: alert_data for alert data or geometry for geometry data

CAPAlert

JSONPathTypeDescription
$.alerts[].idstringUnique alert identifier. Do not parse it for business logic.
$.alerts[].region_codestringISO 3166-1 Alpha-2 code
$.alerts[].sourcenumberAlert source. See CAPAlertSource
$.alerts[].msg_typenumberCAP msgType. See CAPAlertMsgType
$.alerts[].event_namestringEvent name, preferring the selected response language
$.alerts[].categoriesarray<number>CAP info.category. Currently only the Met type is returned. See CAPAlertCategory
$.alerts[].urgencynumberCAP info.urgency. See CAPAlertUrgency
$.alerts[].severitynumberCAP info.severity. See CAPAlertSeverity
$.alerts[].certaintynumberCAP info.certainty. See CAPAlertCertainty
$.alerts[].sent_timenumberSent timestamp in seconds
$.alerts[].effective_timenumberEffective timestamp in seconds
$.alerts[].onset_timenumberOnset timestamp in seconds
$.alerts[].expires_timenumberExpiration timestamp in seconds
$.alerts[].referencesarray<string>CAP references
$.alerts[].areasarray<CAPAlertArea>Affected areas
$.alerts[].language_codestringLanguage code of the returned text
$.alerts[].sender_namestringSender name
$.alerts[].headlinestringHeadline
$.alerts[].descriptionstringAlert description
$.alerts[].instructionstringRecommended instructions

CAPAlertArea

JSONPathTypeDescription
$.alerts[].areas[].area_descstringArea description
$.alerts[].areas[].geocodesarray<CAPAlertGeocode>Area geocodes
$.alerts[].areas[].polygonsarray<CAPAlertPolygon>Polygon geometries
$.alerts[].areas[].geocode_polygonsarray<CAPAlertGeocodePolygon>Polygon geometries supplemented from area geocodes
$.alerts[].areas[].circlesarray<CAPAlertCircle>Circle geometries
$.alerts[].areas[].altitudenumberCAP altitude, in meters
$.alerts[].areas[].ceilingnumberCAP ceiling, in meters

CAPAlertGeocode

JSONPathTypeDescription
$.alerts[].areas[].geocodes[].value_namestringGeocode name
$.alerts[].areas[].geocodes[].valuestringGeocode value
$.alerts[].areas[].geocodes[].namespacestringGeocode namespace

CAPAlertPolygon

JSONPathTypeDescription
$.alerts[].areas[].polygons[].verticesarray<LatLng>Polygon vertices with latitude/longitude fields

CAPAlertGeocodePolygon

JSONPathTypeDescription
$.alerts[].areas[].geocode_polygons[].ringsarray<CAPAlertPolygonRing>Polygon rings. The first is the exterior; subsequent rings are holes.

CAPAlertPolygonRing

JSONPathTypeDescription
$.alerts[].areas[].geocode_polygons[].rings[].verticesarray<LatLng>Ring vertices with latitude/longitude fields

CAPAlertCircle

JSONPathTypeDescription
$.alerts[].areas[].circles[].centerLatLngCircle center with latitude/longitude fields
$.alerts[].areas[].circles[].radius_kmnumberRadius 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