限行天气联动 API 接入文档traffic-weather-alert
输入国内城市拼音(兼容中文),返回当天的限行尾号。如遇暴雨/台风等恶劣天气,附加居家办公建议。覆盖北京、天津、成都、杭州、贵阳、长春 6 个限行城市,天气支持所有国内主要城市。
1. 基本信息
| 接口地址 | https://v1.apizero.cn/api/traffic-weather-alert |
|---|---|
| 请求方法 | GET |
| 分类 | life |
| 提供方 | 极数本源 |
| 计费模式 | 免费试用 |
| 单次消耗 | 0 积分 |
| 起步价 | — |
| QPS 限制 | 3 req/s |
| 每日免费额度 | 10000 次(已认证用户) |
| 匿名每日额度 | 5000 次(无 API Key) |
| VIP 免费 | 否 |
| 调用次数 |
2. 认证
匿名可调用:QPS 1 / 每日 50 次。登录用户:QPS 3 / 每日 100 次。
获取 API Key:登录 https://apizero.cn/account/keys
3. 请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
city | string | 是 | 城市拼音(如 beijing/chengdu/hangzhou),兼容中文(如 北京/成都) | beijing |
action | string | 否 | 操作:restriction(默认)/ cities(支持限行的城市列表) | restriction |
4. 请求头
| Header | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
Authorization | string | 否 | — | — |
5. 请求示例
以下 5 种语言示例都是可直接运行的,只需把 YOUR_API_KEY 替换为实际 Key。
cURL
curl "https://v1.apizero.cn/api/traffic-weather-alert?city=beijing&action=restriction&key=YOUR_API_KEY"Python
import requests
resp = requests.get(
"https://v1.apizero.cn/api/traffic-weather-alert",
params={
"city": "beijing",
"action": "restriction",
"key": "YOUR_API_KEY",
},
timeout=15,
)
resp.raise_for_status()
print(resp.json())JavaScript (Node.js)
// Node.js 18+ / 浏览器原生 fetch
const params = new URLSearchParams({
"city": "beijing",
"action": "restriction",
"key": "YOUR_API_KEY",
});
const res = await fetch(`https://v1.apizero.cn/api/traffic-weather-alert?${params}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
console.log(data);Go
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://v1.apizero.cn/api/traffic-weather-alert", nil)
q := req.URL.Query()
q.Set("city", "beijing")
q.Set("action", "restriction")
q.Set("key", "YOUR_API_KEY")
req.URL.RawQuery = q.Encode()
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}PHP
<?php
$url = "https://v1.apizero.cn/api/traffic-weather-alert?" . http_build_query([
"city" => "beijing",
"action" => "restriction",
"key" => "YOUR_API_KEY",
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$body = curl_exec($ch);
curl_close($ch);
$data = json_decode($body, true);
print_r($data);6. 响应字段
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
city | string | 城市拼音 | — |
city_cn | string | 城市中文名 | — |
date | string | 查询日期(ISO) | — |
weekday | string | 今天星期几(中文) | — |
restricted_numbers | string|null | 限行尾号(如 "4,9"),不限行为 null | — |
restriction_active | boolean | 今日是否限行 | — |
weather.weather | string | 天气描述 | — |
weather.temperature | string | 温度(带 °C) | — |
weather.is_severe | boolean | 是否恶劣天气 | — |
weather.severe_type | string|null | 恶劣天气类型(暴雨/台风等) | — |
work_from_home_advisory | string|null | 居家办公建议(无恶劣天气为 null) | — |
message | string | 综合提示 | — |
7. 响应示例
{
"code": 0,
"msg": "成功",
"data": {
"city": "beijing",
"city_cn": "北京",
"date": "2026-05-11",
"weekday": "周一",
"restricted_numbers": "5,0",
"restriction_active": true,
"weather": {
"weather": "晴",
"temperature": "26°C",
"is_severe": false,
"severe_type": null
},
"work_from_home_advisory": null,
"message": "今日北京(周一)限行尾号为 5,0"
},
"request_id": "abc123"
}8. 错误码
| code | status | 说明 |
|---|---|---|
4000 | — | city 缺失或格式不正确 / action 不合法 |
4029 | — | 调用过快(QPS 超限) |
4030 | — | 今日额度用完 |
9. 变更日志
- 1.0.0(2026-05-10)
- 首次上线,6 城限行 + wttr.in 天气 + 恶劣天气联动
常见问题
限行天气联动 接口怎么免费使用?
未登录用户每个 IP 每天 5000 次免费。登录用户创建 API Key 后每天 10000 次免费,超额部分按点数计费(0 点/次)。
限行天气联动 支持哪些调用方式?
接口使用 GET 请求。文档提供 cURL、Python、JavaScript (Node.js)、Go、PHP 五种语言的可运行示例。也可以下载 /openapi.json 导入 Postman / Insomnia / Apifox 反向生成 SDK。
调用不限额么? QPS 是多少?
本接口 QPS 限制 3 req/s,每个 API Key 每日免费 10000 次。需要更高额度可升级 VIP 套餐或联系售后提高 QPS。
这个接口跟自己直连上游有什么区别?
极数本源 作为中间层提供:统一鉴权(一个 Key 调所有接口)、统一计费(点数制)、统一限流、统一错误码、多上游自动切换。免去逐个对接上游、维护 Key、统计调用量的运维成本。