- 欢迎使用
- 省市区
- 新闻接口
- 注册和登录
- 图书管理
- 图片上传
- 个人信息
- 天气预报
- 商品分类
- 学习反馈
- 作业接口
- 其他接口
获取-天气预报
GET
https://hmajax.itheima.net/api/weather
AJAX编程/天气预报
请求参数
Query 参数
city
string
必需
示例值:
110100
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request GET 'https://hmajax.itheima.net/api/weather?city=110100'
返回响应
🟢200成功
application/json
Body
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": "东南风"
}
]
}
}
🟠400请求参数缺失_AJAX
🟠400没有查询到数据
修改于 2023-09-08 02:48:32