获取天气V1
基于城市ID获取实时天气信息,包含当前温度、湿度、空气质量、PM2.5/PM10、感冒指数以及昨天和未来4天的天气预报数据。接口免费使用,每8小时CDN缓存更新一次。
接口信息
GET
https://api.xunjinlu.fun/api/weather/index.php
Method
GET
分类
未分类
Calls
255
KEY
无需 KEY
计费
免费
QPM
不限制
鉴权方式
无需密钥
作者
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| key | string | 否 | 平台 API 访问密钥(选填) | sk_xxxxxxxxxxxxxxxx |
| cityId | string | 是 | 城市ID编码,如101030100(天津),需从city.json获取对应城市code | |
| format | string | 否 | 返回格式,默认json,可选xml |
[
{
"name": "key",
"type": "string",
"required": false,
"description": "平台 API 访问密钥(选填)",
"example": "sk_xxxxxxxxxxxxxxxx"
},
{
"name": "cityId",
"type": "string",
"required": true,
"description": "城市ID编码,如101030100(天津),需从city.json获取对应城市code",
"example": ""
},
{
"name": "format",
"type": "string",
"required": false,
"description": "返回格式,默认json,可选xml",
"example": ""
}
]
返回示例
{
"code": 200,
"message": "success",
"time": "2026-03-08 14:30:25",
"data": {
"update_time": "2026-03-08 14:30:00",
"city_info": {
"city": "天津市",
"city_id": "101030100",
"parent": "天津",
"weather_update_time": "14:25"
},
"current": {
"date": "20260308",
"temperature": "24",
"humidity": "22%",
"pm25": 15,
"pm10": 46,
"quality": "优",
"cold_index": "各类人群可自由活动"
},
"yesterday": {
"date": "07",
"ymd": "2026-03-07",
"week": "星期六",
"sunrise": "06:30",
"high": "高温 25.0℃",
"low": "低温 15.0℃",
"sunset": "18:15",
"aqi": 108,
"fx": "西北风",
"fl": "4-5级",
"type": "晴",
"notice": "愿你拥有比阳光明媚的心情"
},
"forecast": [
{
"date": "08",
"ymd": "2026-03-08",
"week": "星期日",
"sunrise": "06:28",
"high": "高温 26.0℃",
"low": "低温 16.0℃",
"sunset": "18:16",
"aqi": 55,
"fx": "东南风",
"fl": "3-4级",
"type": "多云",
"notice": "愿你拥有比阳光明媚的心情"
}
]
}
}
接口反馈
暂无详细文档
快速上手
暂无代码示例。管理员可在后台用 AI 生成或手动编写。
免责声明
使用本平台接口即表示同意本声明。
- 数据来源:接口数据来自第三方公开网络或用户上传,本平台不保证准确性、完整性、实时性,请以官方信息为准。
- 合法性与安全性:本平台无法核实每个接口的安全性、合法性,使用者自行承担相关风险。
- 用途限制:标注“学习专用”的接口禁止商用;严禁用于违法违规行为(如诈骗、赌博、侵权等)。违规后果由使用者自行承担。
- 损害免责:使用本接口产生的任何直接或间接损失,本平台不承担责任。
- 第三方上传:用户/商户上传的接口若侵权或违法,由上传者承担全部责任。
- 监督配合:本平台依法记录访问日志,如发现违法活动将配合执法部门处理,并有权随时限制或封禁服务。
注:本平台保留最终解释权,并可能随时更新本声明。
在线测试
请求地址
https://api.xunjinlu.fun/api/weather/index.php
参数
Response
等待中
// 结果将在此处显示