文档天气查询 API
天气查询 API
实时天气与 7 天预报
概述
GET /v1/life/weather 提供实时天气查询和 7 天天气预报。支持按城市名或经纬度查询。
使用模式
| 模式 | 示例 | 说明 |
|---|---|---|
| 城市实时天气 | ?city=北京 | 指定城市当前天气 |
| 坐标实时天气 | ?location=39.90,116.40 | 经纬度当前天气 |
| 含 7 天预报 | ?city=北京&forecast=true | 当前天气 + 7 天预报 |
请求参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
city | string | city 或 location 二选一 | - | 城市名称 |
location | string | city 或 location 二选一 | - | 经纬度坐标(lat,lng) |
forecast | bool | 否 | false | 是否包含 7 天预报 |
请求示例
城市天气
curl -H "X-API-Key: sk_gapi_xxxxx" \
"https://api.groundapi.net/v1/life/weather?city=北京"含预报
curl -H "X-API-Key: sk_gapi_xxxxx" \
"https://api.groundapi.net/v1/life/weather?city=上海&forecast=true"响应字段
实时天气
| 字段 | 说明 |
|---|---|
location | 查询位置 |
current.temp | 当前温度(°C) |
current.text | 天气状况描述 |
current.humidity | 相对湿度(%) |
current.wind_dir | 风向 |
current.wind_speed | 风速(km/h) |
current.pressure | 气压(hPa) |
current.vis | 能见度(km) |
7 天预报(forecast=true)
| 字段 | 说明 |
|---|---|
forecast[].date | 日期 |
forecast[].temp_max | 最高温度(°C) |
forecast[].temp_min | 最低温度(°C) |
forecast[].text_day | 白天天气 |
forecast[].text_night | 夜间天气 |
计费
$0.01/次(news)。每月前 500 次免费。
6 天前更新