NIED WebSocket API 字段说明文档
日本地震预警数据推送服务接口文档
连接地址:
wss://sismotide.top/nied
概述
本文档描述了 NIED 数据推送服务通过 WebSocket 向客户端推送的所有消息格式和字段说明。
数据格式:所有消息均为 JSON 格式,使用 UTF-8 编码
消息类型
详细字段说明
Welcome
Update
Heartbeat
Pong
时间戳说明
Welcome 消息(欢迎消息)
触发时机:客户端成功建立 WebSocket 连接后立即发送
消息格式
{
"type": "welcome",
"message": "已连接到NIED数据推送服务",
"timestamp": 1630000000000
}
字段说明
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
type |
string | 是 | 消息类型,固定值 "welcome" |
message |
string | 是 | 欢迎消息文本 |
timestamp |
number | 是 | 时间戳(毫秒),Unix 时间戳 |
Update 消息(数据更新)
触发时机:
- 检测到新的预警数据时,立即推送给所有客户端
- 新客户端连接时,如果有缓存数据,立即推送最新一条缓存数据
消息格式
{
"type": "update",
"data": {
"result": {
"status": "success",
"message": "",
"is_auth": true
},
"report_time": "2025/11/09 20:11:43",
"region_code": "",
"request_time": "202511092011%s",
"region_name": "三陸沖",
"longitude": "143.7",
"is_cancel": false,
"depth": "20km",
"calcintensity": "2",
"is_final": false,
"is_training": false,
"latitude": "39.3",
"origin_time": "20251109201126",
"security": {
"realm": "/kyoshin_monitor/static/jsondata/eew_est/",
"hash": "b61e4d95a8c42e004665825c098a6de4"
},
"magunitude": "4.6",
"report_num": "1",
"request_hypo_type": "eew",
"report_id": "20251109201130",
"alertflg": "予報"
},
"timestamp": 1762689403835,
"from_cache": true
}
外层字段说明
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
type |
string | 是 | 消息类型,固定值 "update" |
data |
object | 是 | 预警数据对象 |
timestamp |
number | 是 | 消息发送时间戳(毫秒),Unix 时间戳 |
from_cache |
boolean | 否 | 是否为缓存数据。true 表示从缓存推送,false 表示实时新数据 |
data 对象字段说明
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
result |
object | 是 | 请求结果对象 |
report_time |
string | 是 | 报告时间,格式为 "YYYY/MM/DD HH:MM:SS" |
region_code |
string | 是 | 区域代码 |
request_time |
string | 是 | 请求时间,格式为 "YYYYMMDDHHMM%s" |
region_name |
string | 是 | 区域名称 |
longitude |
string | 是 | 震中经度(度) |
is_cancel |
boolean | 是 | 是否为取消报告 |
depth |
string | 是 | 震源深度(公里) |
calcintensity |
string | 是 | 计算烈度 |
is_final |
boolean | 是 | 是否为最终报告 |
is_training |
boolean | 是 | 是否为训练模式 |
latitude |
string | 是 | 震中纬度(度) |
origin_time |
string | 是 | 发震时间,格式为 "YYYYMMDDHHMMSS" |
security |
object | 是 | 安全验证对象 |
magunitude |
string | 是 | 震级(注意:字段名拼写为 magunitude) |
report_num |
string | 是 | 报告编号 |
request_hypo_type |
string | 是 | 请求类型,固定值 "eew" |
report_id |
string | 是 | 报告ID,格式为 "YYYYMMDDHHMMSS" |
alertflg |
string | 是 | 警报标志,可能值为 "予報" 等 |
result 对象字段说明
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
status |
string | 是 | 请求状态,固定值 "success" |
message |
string | 是 | 状态消息 |
is_auth |
boolean | 是 | 是否已认证 |
security 对象字段说明
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
realm |
string | 是 | 安全域路径 |
hash |
string | 是 | 安全哈希值 |
Heartbeat 消息(心跳包)
触发时机:每 30 秒自动向所有连接的客户端发送一次
消息格式
{
"type": "heartbeat",
"ver": "0.1.1",
"id": "550e8400-e29b-41d4-a716-446655440000",
"timestamp": 1630000000000
}
字段说明
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
type |
string | 是 | 消息类型 |
ver |
string | 是 | 心跳包版本号 |
id |
string | 是 | 心跳包唯一标识符 |
timestamp |
number | 是 | 心跳包发送时间戳 |
用途说明
- 用于保持 WebSocket 连接活跃
- 客户端可以通过心跳包检测连接是否正常
- 每次心跳包的
id都是唯一的,可用于追踪
Pong 消息(Pong响应)
触发时机:客户端发送 ping 消息时,服务端立即响应
消息格式
{
"type": "pong",
"timestamp": 1630000000000
}
字段说明
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
type |
string | 是 | 消息类型,固定值 "pong" |
timestamp |
number | 是 | 响应时间戳(毫秒),Unix 时间戳 |
客户端请求格式
客户端发送的 ping 消息格式:
{
"type": "ping"
}
时间戳说明
所有时间戳字段均为:
时间戳字段分布
| 字段名 | 消息类型 | 说明 |
|---|---|---|
timestamp |
所有消息 | 消息发送时间戳 |
report_time |
Update | 报告时间,UTC+9 时区 |
origin_time |
Update | 发震时间,UTC+9 时区 |
注意事项
- 无效路径会立即关闭连接
- 客户端需自行实现断线重连逻辑
- 数据格式与对应业务接口一致
- 长时间无操作建议主动发送心跳
- 数据来源: NIED日本防災科研所
- 更新规则: 收到新预警或更新后立即推送