获得天气相关接口四-获得15日天气预报

之前提供了获得当日天气信息的接口,本次将介绍获得15日天气预报的接口,还是以城市编码为查询条件,查询15日天气列表。本文为系列文档,有需要的人可能需要从第一篇文章看起,有调用说明以及请求域名、限流说明等等。

请求路径:

/weather/15d

请求方法:GET

请求参数:

请求参数
参数名称参数类型是否必须参数说明
code string城市编码

返回参数:

返回参数
参数名称参数类型是否必须参数说明
codeint1为成功,其他为失败
msgstring返回信息
datalist返回数据
.datestring日期
.weekstring周几
.weatherstring天气
.max_tempint最高温度
.min_tempint最低温度
.air_qualityint空气质量
.air_quality_tipstring空气质量说明
.sunrisestring日出时间
.sunsetstring日落时间
timestring请求时间

返回样例:

{
  "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日天气尤其是除当日天气,变化较小,所以可以使用缓存。同时也建议调用方也增加短时缓存,减少请求次数。

如有问题欢迎评论或者私信询问。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

U.N. B

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值