Skip to Content
中云易冰

查询天气

可使用中文城市名、城市 ID、locationKey 或经纬度查询。优先级依次为 city、cityId、locationKey、经纬度。

GET
/v1/weather

Query Parameters

city?string

中文城市名称。

cityId?string

中国天气城市 ID,例如北京为 101010100。

Match^[0-9]+$
locationKey?string

小米天气位置键。

lat?number

纬度;也兼容 latitude 参数。

Range-90 <= value <= 90
lon?number

经度;也兼容 lng 或 longitude 参数。

Range-180 <= value <= 180
days?integer

请求预报天数。服务端会限制在 1 至 15 天,默认 7 天。

Range1 <= value <= 15
Default7

Response Body

天气查询成功

application/json
  1. response
ok*boolean
location*
days*integer
Range1 <= value <= 15
weather*

小米天气上游返回的数据。字段可能随地区和上游版本变化。

Example Request
curl -X GET 'https://weather.api.236668.xyz/v1/weather?city=%E5%8C%97%E4%BA%AC&cityId=101010100&locationKey=weathercn%3A101010100&lat=39.904&lon=116.408&days=7'
Example Response
{  "ok": true,  "location": {    "affiliation": "string",    "key": "string",    "locationKey": "string",    "name": "string",    "latitude": "string",    "longitude": "string",    "status": 0,    "timeZoneShift": 0  },  "days": 1,  "weather": {    "current": {},    "forecastDaily": {},    "forecastHourly": {},    "aqi": {},    "alerts": [      {}    ],    "minutely": {},    "updateTime": 0  }}