发现一个可以免费查询天气情况的api:温度、湿度、AQI、天气、风向等。
1、先查询所有城市cityid:
接口URL:(GET)http://send.wxbus163.cn/weather/getCityList
结果:
{
"code": 200,
"msg": "ok",
"list": [
{
"id": 2001,
"cityname": "北京"
},
{
"id": 2002,
"cityname": "海淀"
},
{
"id": 2003,
"cityname": "朝阳"
},
{
"id": 2004,
"cityname": "顺义"
},
{
"id": 2005,
"cityname": "怀柔"
},
.
.
.
.
]
}
2、查询当天天气:
接口URL:
(POST) http://send.wxbus163.cn/weather/getToday
Body 请求参数
参数名 参数值 是否必填 参数类型 描述说明
cityid 4840 是 String 城市id
{
"status": 200,
"msg": "ok",
"list": {
"cityname": "北京",
"today": "06月27日(星期四)",
"max_temp": "35℃",
"min_temp": "24℃",
"now_temp": "32.6℃",
"weather": "多云",
"weathercode": "https://i.i8tq.com/e_index/todayweather/01_d.png",
"aqi": "56",
"wind": "西南风3级",
"humidity": "30%",
"air": "1002",
"visibility": "24km",
"shzhishu": [
{
"title": "穿衣",
"des": "短袖"
},
{
"title": "跑步",
"des": "较适宜"
},
{
"title": "钓鱼",
"des": "较适宜"
},
{
"title": "洗车",
"des": "适宜"
},
{
"title": "晾晒",
"des": "适宜"
},
{
"title": "污染",
"des": "中"
}
]
}
}
3、查询未来15天天气状况:
接口URL:
(POST )http://send.wxbus163.cn/weather/get15Weather
Body 请求参数
参数名 参数值 是否必填 参数类型 描述说明
cityid 4840 是 String 城市id
{
"status": 200,
"msg": "ok",
"list": {
"1": {
"date": "6/27",
"week": "今天",
"max_temp": "35℃",
"min_temp": "29℃",
"weather": "雷阵雨",
"day_icon": "https://i.i8tq.com/e_index/blueTemperature/04.png",
"night_icon": "https://i.i8tq.com/e_index/blueTemperature/04.png"
},
"2": {
"date": "6/28",
"week": "星期五",
"max_temp": "35℃",
"min_temp": "28℃",
"weather": "雷阵雨",
"day_icon": "https://i.i8tq.com/e_index/blueTemperature/04.png",
"night_icon": "https://i.i8tq.com/e_index/blueTemperature/01_n.png"
},
...
...
...
"15": {
"date": "7/11",
"week": "星期四",
"max_temp": "34℃",
"min_temp": "28℃",
"weather": "雨",
"day_icon": "https://i.i8tq.com/e_index/blueTemperature/301.png",
"night_icon": "https://i.i8tq.com/e_index/blueTemperature/301.png"
}
}
}
开发文档参考来源:https://console-docs.apipost.cn/preview/8cafe72ecd5ddecc/7f1676f5f3ea5fa1?target_id=34bc097c-0bdf-4385-bfe6-af251665ede9