天气预报查询API提供全国城市实时天气和未来5天预报数据。只需传入城市名称,即可获取温度、湿度、风向风力、空气质量等详细信息。
天气预报查询API提供全国城市实时天气和未来5天预报数据。只需传入城市名称,即可获取温度、湿度、风向风力、空气质量等详细信息。
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| city | string | 是 | 城市名称,如:北京、上海、广州。支持中文名称。 |
[
{
"name": "city",
"type": "string",
"required": true,
"description": "城市名称,如:北京、上海、广州。支持中文名称。",
"example": ""
}
]{"openapi":"3.1.1","info":{"title":"天气预报查询","description":"天气预报查询API提供全国城市实时天气和未来5天预报数据。只需传入城市名称,即可获取温度、湿度、风向风力、空气质量等详细信息。","version":"1.0.0"},"paths":{"/apis/gateway?api=weather":{"get":{"summary":"天气预报查询","description":"天气预报查询API提供全国城市实时天气和未来5天预报数据。只需传入城市名称,即可获取温度、湿度、风向风力、空气质量等详细信息。","parameters":[{"name":"city","in":"query","required":true,"schema":{"type":"string"},"description":"城市名称,如:北京、上海、广州。支持中文名称。"}],"responses":{"200":{"description":"成功","content":{"application/json":{"schema":{"type":"object"}}}}}},"post":{"summary":"天气预报查询","description":"天气预报查询API提供全国城市实时天气和未来5天预报数据。只需传入城市名称,即可获取温度、湿度、风向风力、空气质量等详细信息。","parameters":[{"name":"city","in":"query","required":true,"schema":{"type":"string"},"description":"城市名称,如:北京、上海、广州。支持中文名称。"}],"responses":{"200":{"description":"成功","content":{"application/json":{"schema":{"type":"object"}}}}}}}},"servers":[{"url":"https://api.souxiaocha.com","description":"当前访问入口(https)"}]}
{"success":true,"data":{"city":"上海","realtime":{"temperature":"33","humidity":"62","info":"多云","wid":"01","direct":"东北风","power":"4-5级","aqi":"17"},"future":[{"date":"2026-07-29","temperature":"29\/37℃","weather":"多云转晴","wid":{"day":"01","night":"00"},"direct":"东南风"},{"date":"2026-07-30","temperature":"29\/38℃","weather":"多云转晴","wid":{"day":"01","night":"00"},"direct":"南风转东南风"},{"date":"2026-07-31","temperature":"29\/37℃","weather":"多云转晴","wid":{"day":"01","night":"00"},"direct":"东南风"},{"date":"2026-08-01","temperature":"29\/38℃","weather":"阴转晴","wid":{"day":"02","night":"00"},"direct":"东南风"},{"date":"2026-08-02","temperature":"28\/37℃","weather":"阴转晴","wid":{"day":"02","night":"00"},"direct":"东风"}]},"generated_at":"2026-07-29 13:59:26"}https://api.souxiaocha.com/apis/gateway?api=weatherGET https://api.souxiaocha.com/apis/gateway?api=weather apikey=你的API密钥&city=请填写city
GET 参数放在查询字符串中。参数值请替换为实际有效值。
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
city | string | 是 | 城市名称,如:北京、上海、广州。支持中文名称。 |
{"success":true,"data":{"city":"上海","realtime":{"temperature":"33","humidity":"62","info":"多云","wid":"01","direct":"东北风","power":"4-5级","aqi":"17"},"future":[{"date":"2026-07-29","temperature":"29\/37℃","weather":"多云转晴","wid":{"day":"01","night":"00"},"direct":"东南风"},{"date":"2026-07-30","temperature":"29\/38℃","weather":"多云转晴","wid":{"day":"01","night":"00"},"direct":"南风转东南风"},{"date":"2026-07-31","temperature":"29\/37℃","weather":"多云转晴","wid":{"day":"01","night":"00"},"direct":"东南风"},{"date":"2026-08-01","temperature":"29\/38℃","weather":"阴转晴","wid":{"day":"02","night":"00"},"direct":"东南风"},{"date":"2026-08-02","temperature":"28\/37℃","weather":"阴转晴","wid":{"day":"02","night":"00"},"direct":"东风"}]},"generated_at":"2026-07-29 13:59:26"}天气预报查询API提供全国城市实时天气和未来5天预报数据。只需传入城市名称,即可获取温度、湿度、风向风力、空气质量等详细信息。
https://api.souxiaocha.com/apis/gateway?api=weather
GET / POST(业务参数 GET 通过 URL 传递,POST 支持表单或 JSON)
调用需携带平台密钥(用户中心「令牌管理」获取,SK- 开头):
key=SK-你的密钥X-API-Key: SK-你的密钥| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| city | string | 是 | 城市名称,如:北京、上海、广州。支持中文名称。 |
[
{"name": "city", "type": "string", "required": true, "description": "城市名称,如:北京、上海、广州。支持中文名称。"}
]
成功返回示例:
{"success":true,"data":{"city":"上海","realtime":{"temperature":"33","humidity":"62","info":"多云","wid":"01","direct":"东北风","power":"4-5级","aqi":"17"},"future":[{"date":"2026-07-29","temperature":"29\/37℃","weather":"多云转晴","wid":{"day":"01","night":"00"},"direct":"东南风"},{"date":"2026-07-30","temperature":"29\/38℃","weather":"多云转晴","wid":{"day":"01","night":"00"},"direct":"南风转东南风"},{"date":"2026-07-31","temperature":"29\/37℃","weather":"多云转晴","wid":{"day":"01","night":"00"},"direct":"东南风"},{"date":"2026-08-01","temperature":"29\/38℃","weather":"阴转晴","wid":{"day":"02","night":"00"},"direct":"东南风"},{"date":"2026-08-02","temperature":"28\/37℃","weather":"阴转晴","wid":{"day":"02","night":"00"},"direct":"东风"}]},"generated_at":"2026-07-29 13:59:26"}
失败返回示例:
{"success":false,"error":"missing_city","message":"请提供城市名称参数(city)"}
| 参数名 | 类型 | 说明 |
|---|---|---|
| success | boolean | 请求是否成功 |
| data.city | string | 城市名称 |
| data.realtime.temperature | string | 当前温度(℃) |
| data.realtime.humidity | string | 湿度(%) |
| data.realtime.info | string | 天气情况(晴、多云、雨等) |
| data.realtime.direct | string | 风向 |
| data.realtime.power | string | 风力等级 |
| data.realtime.aqi | string | 空气质量指数 |
| data.future[].date | string | 预报日期 |
| data.future[].temperature | string | 温度范围(最低/最高℃) |
| data.future[].weather | string | 天气情况 |
| data.future[].direct | string | 风向 |
| generated_at | string | 数据生成时间 |
curl "https://api.souxiaocha.com/apis/gateway?api=weather?key=SK-你的密钥&city=%E5%8C%97%E4%BA%AC"
上游业务级错误:
| code | msg | 描述 |
|---|---|---|
| 400 | missing_city | 缺少城市名称参数 |
| 401 | invalid_api_key | API密钥无效或未提供 |
| 500 | config_error | 服务配置异常 |
| 500 | api_request_failed | 第三方接口请求异常 |
| 500 | api_parse_failed | 第三方接口响应解析失败 |
| 500 | query_failed | 天气查询失败(城市不存在等) |
平台级错误(errcode):11001 缺少密钥 / 11002 密钥无效或已禁用 / 11005 接口禁用 / 11006 接口维护 / 11010 积分不足 / 11018 请求方式不允许。
失败时请以响应体中的 code / errcode 与 msg 判断。
2026-09-24
curl "https://api.souxiaocha.com/apis/gateway?api=weather?key=SK-你的密钥&city=%E5%8C%97%E4%BA%AC"
// 结果将在此处显示