获取-天气预报
GET
https://hmajax.itheima.net/api/weather获取-天气预报
请求参数
Query 参数
city
string
必需
城市code,北京市:110100
示例值:
110100
示例代码
返回响应
成功(200)
请求参数缺失_AJAX(400)
没有查询到数据(400)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
code
integer
响应编码
message
string
响应消息
data
object
响应数据
date
string
日期
area
string
地区
dateShort
string
阳历日期
dateLunar
string
农历日期
dayForecast
array [object {8}]
一周天气
psPm25
string
PM指数
psPm25Level
string
PM等级
temperature
string
温度
当日温度
todayWeather
object
今日天气
weather
string
天气
weatherImg
string
天气图片
windDirection
string
风向
windPower
string
风力等级
示例成功示例
{
"code": 10000,
"message": "查询天气成功",
"data": {
"date": "2023-02-12",
"area": "北京市",
"dateShort": "02月12日",
"dateLunar": "正月廿二",
"temperature": "3",
"weather": "霾",
"weatherImg": "https://hmajax.itheima.net/weather/mailine.png",
"windPower": "1级",
"windDirection": "东风",
"psPm25Level": "中度",
"psPm25": "172",
"todayWeather": {
"humidity": "69.0",
"sunriseTime": "07:12",
"sunsetTime": "17:46",
"ultraviolet": "最弱",
"weather": "雨夹雪",
"temDay": "3",
"temNight": "-5"
},
"dayForecast": [
{
"date": "02月12日",
"temDay": "3",
"weather": "雨夹雪",
"temNight": "-5",
"windPower": "<3级",
"dateFormat": "今天",
"weatherImg": "https://hmajax.itheima.net/weather/yujiaxue.png",
"windDirection": "东北风"
},
{
"date": "02月13日",
"temDay": "7",
"weather": "晴",
"temNight": "-4",
"windPower": "<3级",
"dateFormat": "明天",
"weatherImg": "https://hmajax.itheima.net/weather/qing.png",
"windDirection": "北风"
},
{
"date": "02月14日",
"temDay": "6",
"weather": "多云",
"temNight": "-5",
"windPower": "<3级",
"dateFormat": "后天",
"weatherImg": "https://hmajax.itheima.net/weather/duoyun.png",
"windDirection": "南风"
},
{
"date": "02月15日",
"temDay": "4",
"weather": "多云",
"temNight": "-6",
"windPower": "<3级",
"dateFormat": "周三",
"weatherImg": "https://hmajax.itheima.net/weather/duoyun.png",
"windDirection": "南风"
},
{
"date": "02月16日",
"temDay": "6",
"weather": "晴",
"temNight": "-5",
"windPower": "<3级",
"dateFormat": "周四",
"weatherImg": "https://hmajax.itheima.net/weather/qing.png",
"windDirection": "南风"
},
{
"date": "02月17日",
"temDay": "4",
"weather": "多云",
"temNight": "0",
"windPower": "<3级",
"dateFormat": "周五",
"weatherImg": "https://hmajax.itheima.net/weather/duoyun.png",
"windDirection": "北风"
},
{
"date": "02月18日",
"temDay": "6",
"weather": "多云",
"temNight": "-1",
"windPower": "<3级",
"dateFormat": "周六",
"weatherImg": "https://hmajax.itheima.net/weather/duoyun.png",
"windDirection": "东南风"
}
]
}
}
最后修改时间: 10 个月前