Skip to content

批量获取 API

访问限制

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

TIP

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

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

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

调用方式:

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

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

请求参数:

FieldTypeRequiredDescription
region_codestring地区编码,默认值为 US,目前仅支持 US
languagestring返回文本语言,目前 US 仅支持 en-US;不支持的语言会回落到 en-US

返回结构

json
{
  "result": {
    "url": "https://cdn.example.com/dvf/develop/cap-alert/all/US/en-US/latest.geojson?sign=1",
    "updated_at": 1750123200
  }
}

GetAllCAPAlertsResponse

FieldTypeDescription
resultCAPAlertDownloadResult 对象下载结果

CAPAlertDownloadResult

FieldTypeDescription
urlstring带签名的 GeoJSON 下载地址
updated_atint64GeoJSON 文件更新时间戳(秒)

下载文件结构

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"
          }
        ]
      }
    }
  ]
}

FeatureCollection

FieldTypeDescription
typestring固定为 FeatureCollection
featuresFeature 数组CAP 气象预警影响范围

Feature

FieldTypeDescription
typestring固定为 Feature
geometryGeoJSON Geometry预警区域范围,可能为 Polygon 或圆形近似多边形
idstring当前范围的唯一标识
propertiesCAPAlertFeaturePropertiesCAP 气象预警属性

CAPAlertFeatureProperties

FieldTypeDescription
idstring预警唯一标识
region_codestringISO 3166-1 Alpha-2 code
sourceint32预警来源机构,参考 CAPAlertSource
msg_typeint32CAP msgType,参考 CAPAlertMsgType
event_namestring事件名称
categoriesint32 数组CAP info.category,目前只返回 Met 类型,参考 CAPAlertCategory
urgencyint32CAP info.urgency,参考 CAPAlertUrgency
severityint32CAP info.severity,参考 CAPAlertSeverity
certaintyint32CAP info.certainty,参考 CAPAlertCertainty
sent_timeint64发送时间戳(秒)
effective_timeint64生效时间戳(秒)
onset_timeint64事件开始时间戳(秒)
expires_timeint64过期时间戳(秒)
referencesstring 数组CAP references
language_codestring当前返回文本的语言编码
sender_namestring发布机构名称
headlinestring标题
descriptionstring预警描述
instructionstring防御建议或行动指引
area_descstring区域描述
geocodesCAPAlertGeocode 数组区域编码