Skip to content

批量获取 API

访问限制

本部分 API 属于增值服务,仅提供给企业套餐开发者,如需采购请联系彩云商务

TIP

目前支持美国和加拿大地区的 CAP 气象预警信息,其他国家和地区的预警信息正在逐步增加中。

每次调用消耗接口调用额度一次。

本接口重点为需要在地图叠加 CAP 气象预警影响范围的客户提供一个方便的批量获取 API。接口返回一个带签名的 GeoJSON 下载地址,下载文件中的 features 每个元素对应一个预警区域的多边形或圆形范围。

请求

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

查询参数

参数必填默认值取值范围说明
tokenAPI 认证凭证,详见 认证与鉴权
region_codeUSUSCA地区编码
languageen-US(US)/ en-CA(CA)US:en-US;CA:en-CAfr-CA返回文本语言;不支持的语言会回落到对应地区的默认语言

请求示例

美国:

bash
curl "https://singer.caiyunhub.com/v3/cap_alert/all?token={token}&region_code=US&language=en-US"

加拿大(法语):

bash
curl "https://singer.caiyunhub.com/v3/cap_alert/all?token={token}&region_code=CA&language=fr-CA"

接口会在服务端生成或复用 CAP 气象预警 GeoJSON 静态文件,响应中的 result.url 是带签名的下载地址, result.updated_at 是该文件的更新时间戳(秒)。

响应示例

json
{
  "result": {
    "url": "https://cdn.example.com/dvf/develop/cap-alert/all/US/en-US/latest.geojson?sign=1",
    "updated_at": 1750123200
  },
  "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"
    }
  ]
}

响应字段

GetAllCAPAlertsResponse

JSONPath类型说明
$.resultCAPAlertDownloadResult下载结果
$.attributionsarray<CAPAlertAttribution>数据来源、许可证及署名信息

CAPAlertDownloadResult

JSONPath类型说明
$.result.urlstring带签名的 GeoJSON 下载地址
$.result.updated_atnumberGeoJSON 文件更新时间戳(秒)

CAPAlertAttribution

字段类型说明
sourcenumber预警来源机构,参考 CAPAlertSource
providerstring数据或几何信息提供方
source_urlstring数据源地址
attribution_textstring用于展示的署名文本
license_idstring许可证标识
license_urlstring许可证地址,未提供时不返回该字段
terms_urlstring数据源使用条款地址,未提供时不返回该字段
applies_tostring署名信息的适用对象:alert_data 表示预警数据,geometry 表示几何信息

下载文件结构

result.url 指向的 GeoJSON 文件结构如下:

json
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [-118.45, 34.11],
            [-118.10, 34.10],
            [-118.12, 33.90],
            [-118.45, 34.11]
          ]
        ]
      },
      "id": "nws-alert-1:area:0:polygon:0",
      "properties": {
        "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": [],
        "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.",
        "area_desc": "Los Angeles",
        "geocodes": [
          {
            "value_name": "UGC",
            "value": "CAC037",
            "namespace": "NWS_UGC"
          }
        ]
      }
    }
  ],
  "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"
    }
  ]
}

下载文件字段

FeatureCollection

JSONPath类型说明
$.typestring固定为 FeatureCollection
$.featuresarray<Feature>CAP 气象预警影响范围
$.attributionsarray<CAPAlertAttribution>数据来源、许可证及署名信息

Feature

JSONPath类型说明
$.features[].typestring固定为 Feature
$.features[].geometryGeoJSON Geometry预警区域范围,可能为 Polygon 或圆形近似多边形
$.features[].idstring当前范围的唯一标识
$.features[].propertiesCAPAlertFeaturePropertiesCAP 气象预警属性

CAPAlertFeatureProperties

JSONPath类型说明
$.features[].properties.idstring预警唯一标识
$.features[].properties.region_codestringISO 3166-1 Alpha-2 code
$.features[].properties.sourcenumber预警来源机构,参考 CAPAlertSource
$.features[].properties.msg_typenumberCAP msgType,参考 CAPAlertMsgType
$.features[].properties.event_namestring事件名称
$.features[].properties.categoriesarray<number>CAP info.category,目前只返回 Met 类型,参考 CAPAlertCategory
$.features[].properties.urgencynumberCAP info.urgency,参考 CAPAlertUrgency
$.features[].properties.severitynumberCAP info.severity,参考 CAPAlertSeverity
$.features[].properties.certaintynumberCAP info.certainty,参考 CAPAlertCertainty
$.features[].properties.sent_timenumber发送时间戳(秒)
$.features[].properties.effective_timenumber生效时间戳(秒)
$.features[].properties.onset_timenumber事件开始时间戳(秒)
$.features[].properties.expires_timenumber过期时间戳(秒)
$.features[].properties.referencesarray<string>CAP references
$.features[].properties.language_codestring当前返回文本的语言编码
$.features[].properties.sender_namestring发布机构名称
$.features[].properties.headlinestring标题
$.features[].properties.descriptionstring预警描述
$.features[].properties.instructionstring防御建议或行动指引
$.features[].properties.area_descstring区域描述
$.features[].properties.geocodesarray<CAPAlertGeocode>区域编码