之前提供了获得当日天气信息的接口,本次将介绍获得15日天气预报的接口,还是以城市编码为查询条件,查询15日天气列表。本文为系列文档,有需要的人可能需要从第一篇文章看起,有调用说明以及请求域名、限流说明等等。
请求路径:
/weather/15d
请求方法:GET
请求参数:
参数名称 | 参数类型 | 是否必须 | 参数说明 |
code | string | 是 | 城市编码 |
返回参数:
参数名称 | 参数类型 | 是否必须 | 参数说明 |
code | int | 是 | 1为成功,其他为失败 |
msg | string | 是 | 返回信息 |
data | list | 是 | 返回数据 |
.date | string | 是 | 日期 |
.week | string | 是 | 周几 |
.weather | string | 是 | 天气 |
.max_temp | int | 是 | 最高温度 |
.min_temp | int | 是 | 最低温度 |
.air_quality | int | 是 | 空气质量 |
.air_quality_tip | string | 是 | 空气质量说明 |
.sunrise | string | 是 | 日出时间 |
.sunset | string | 是 | 日落时间 |
time | string | 是 | 请求时间 |
返回样例:
{
"code": 1,
"msg": "success",
"data": [
{
"date": "2022-11-08",
"week": "星期二",
"weather": "多云",
"max_temp": "23",
"min_temp": "13",
"air_quality": "54",
"air_quality_tip": "良",
"sunrise": "06:27",
"sunset": "17:09"
},
{
"date": "2022-11-09",
"week": "星期三",
"weather": "多云",
"max_temp": "22",
"min_temp": "14",
"air_quality": "49",
"air_quality_tip": "优",
"sunrise": "06:28",
"sunset": "17:09"
},
{
"date": "2022-11-10",
"week": "星期四",
"weather": "多云",
"max_temp": "25",
"min_temp": "16",
"air_quality": "75",
"air_quality_tip": "良",
"sunrise": "06:28",
"sunset": "17:08"
},
{
"date": "2022-11-11",
"week": "星期五",
"weather": "多云",
"max_temp": "24",
"min_temp": "17",
"air_quality": "38",
"air_quality_tip": "优",
"sunrise": "06:29",
"sunset": "17:07"
},
{
"date": "2022-11-12",
"week": "星期六",
"weather": "小雨",
"max_temp": "27",
"min_temp": "13",
"air_quality": "81",
"air_quality_tip": "良",
"sunrise": "06:30",
"sunset": "17:07"
},
{
"date": "2022-11-13",
"week": "星期日",
"weather": "多云",
"max_temp": "15",
"min_temp": "10",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:31",
"sunset": "17:06"
},
{
"date": "2022-11-14",
"week": "星期一",
"weather": "多云",
"max_temp": "15",
"min_temp": "7",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:32",
"sunset": "17:05"
},
{
"date": "2022-11-15",
"week": "星期二",
"weather": "阴转晴",
"max_temp": "14",
"min_temp": "7",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:33",
"sunset": "17:05"
},
{
"date": "2022-11-16",
"week": "星期三",
"weather": "阴",
"max_temp": "17",
"min_temp": "10",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:34",
"sunset": "17:04"
},
{
"date": "2022-11-17",
"week": "星期四",
"weather": "雨转阴",
"max_temp": "17",
"min_temp": "8",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:35",
"sunset": "17:04"
},
{
"date": "2022-11-18",
"week": "星期五",
"weather": "阴转晴",
"max_temp": "18",
"min_temp": "8",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:35",
"sunset": "17:03"
},
{
"date": "2022-11-19",
"week": "星期六",
"weather": "晴转多云",
"max_temp": "18",
"min_temp": "9",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:36",
"sunset": "17:03"
},
{
"date": "2022-11-20",
"week": "星期日",
"weather": "多云转阴",
"max_temp": "19",
"min_temp": "10",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:37",
"sunset": "17:02"
},
{
"date": "2022-11-21",
"week": "星期一",
"weather": "雨",
"max_temp": "19",
"min_temp": "11",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:38",
"sunset": "17:02"
},
{
"date": "2022-11-22",
"week": "星期二",
"weather": "阴",
"max_temp": "13",
"min_temp": "8",
"air_quality": "",
"air_quality_tip": "",
"sunrise": "06:39",
"sunset": "17:02"
}
],
"time": "2022-11-08 09:27:54"
}
接口提供数据有段时间缓存,15日天气尤其是除当日天气,变化较小,所以可以使用缓存。同时也建议调用方也增加短时缓存,减少请求次数。
如有问题欢迎评论或者私信询问。