批量获取 API
访问限制
本部分 API 属于增值服务,仅提供给企业套餐开发者,如需采购请联系彩云商务
TIP
目前支持美国地区的 CAP 气象预警信息,其他国家和地区的预警信息正在逐步增加中。
每次调用消耗接口调用额度一次。
本接口重点为需要在地图叠加 CAP 气象预警影响范围的客户提供一个方便的批量获取 API。接口返回一个带签名的 GeoJSON 下载地址,下载文件中的 features 每个元素对应一个预警区域的多边形或圆形范围。
调用方式:
bash
curl "https://singer.caiyunhub.com/v3/cap_alert/all?token={token}®ion_code=US&language=en-US"接口会在服务端生成或复用 CAP 气象预警 GeoJSON 静态文件,响应中的 result.url 是带签名的下载地址, result.updated_at 是该文件的更新时间戳(秒)。
请求参数:
| Field | Type | Required | Description |
|---|---|---|---|
| region_code | string | 否 | 地区编码,默认值为 US,目前仅支持 US |
| language | string | 否 | 返回文本语言,目前 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
| Field | Type | Description |
|---|---|---|
| result | CAPAlertDownloadResult 对象 | 下载结果 |
CAPAlertDownloadResult
| Field | Type | Description |
|---|---|---|
| url | string | 带签名的 GeoJSON 下载地址 |
| updated_at | int64 | GeoJSON 文件更新时间戳(秒) |
下载文件结构
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
| Field | Type | Description |
|---|---|---|
| type | string | 固定为 FeatureCollection |
| features | Feature 数组 | CAP 气象预警影响范围 |
Feature
| Field | Type | Description |
|---|---|---|
| type | string | 固定为 Feature |
| geometry | GeoJSON Geometry | 预警区域范围,可能为 Polygon 或圆形近似多边形 |
| id | string | 当前范围的唯一标识 |
| properties | CAPAlertFeatureProperties | CAP 气象预警属性 |
CAPAlertFeatureProperties
| Field | Type | Description |
|---|---|---|
id | string | 预警唯一标识 |
region_code | string | ISO 3166-1 Alpha-2 code |
source | int32 | 预警来源机构,参考 CAPAlertSource |
msg_type | int32 | CAP msgType,参考 CAPAlertMsgType |
event_name | string | 事件名称 |
categories | int32 数组 | CAP info.category,目前只返回 Met 类型,参考 CAPAlertCategory |
urgency | int32 | CAP info.urgency,参考 CAPAlertUrgency |
severity | int32 | CAP info.severity,参考 CAPAlertSeverity |
certainty | int32 | CAP info.certainty,参考 CAPAlertCertainty |
sent_time | int64 | 发送时间戳(秒) |
effective_time | int64 | 生效时间戳(秒) |
onset_time | int64 | 事件开始时间戳(秒) |
expires_time | int64 | 过期时间戳(秒) |
references | string 数组 | CAP references |
language_code | string | 当前返回文本的语言编码 |
sender_name | string | 发布机构名称 |
headline | string | 标题 |
description | string | 预警描述 |
instruction | string | 防御建议或行动指引 |
area_desc | string | 区域描述 |
geocodes | CAPAlertGeocode 数组 | 区域编码 |