全球天气预报5天-经纬度版免费API接口教程

简介: 该接口提供全球任意地区未来5天的天气预报,需输入经纬度参数。支持POST和GET请求方式,返回数据包括天气、气温、气压等详细信息。请求需包含用户ID和KEY,详情及示例参见文档。

接口简介:
获取全球任意地区未来5天天气预报,必须传经纬度参数。可先调用【位置坐标】分类下相关接口获取地区经纬度坐标。

请求地址:
https://cn.apihz.cn/api/tianqi/tqybjw5.php

请求方式:
POST或GET。

请求参数:
【名称】【参数】【必填】【说明】
【用户ID】【id】【是】【用户中心的数字ID,例:id=10000000】
【用户KEY】【key】【是】【用户中心通讯秘钥,例:key=15he5h15ty854j5sr152hs2】
【纬度】【lat】【是】【纬度。例:lat=40.05702706489032】
【经度】【lon】【是】【经度。例:lon=116.30787799999993】

返回参数:
【名称】【参数】【说明】
【状态码】【code】【200成功,400错误】
【消息内容】【msg】【信息提示。】
【数据组数量】【cnt】【每3小时为一组数据,5天一般共计40组数据。】
【消息内容】【msg】【信息提示。】
【国家】【country】【国家代码 ISO。】
【日出】【sunrise】【日出时间戳。】
【日落】【sunset】【日落时间戳。】
【城市】【name】【城市名称。】
【数据组】【data】【天气预报数据集合,每天8组数据,每3小时为1组。】
【天气】【data.weather】【天气。】
【气温】【data.temp】【气温,华氏度。】
【气压】【data.pressure】【气压。】
【湿度】【data.humidity】【湿度百分比。】
【能见度】【data.visibility】【能见度,单位米。】
【风速】【data.speed】【风速,单位米。】
【风向】【data.deg】【风向度。】
【空气质量】【data.clouds】【空气质量,浑浊度,百分比。】

GET请求示例:
https://cn.apihz.cn/api/tianqi/tqybjw5.php?id=88888888&key=88888888&lat=40.05702706489032&lon=116.30787799999993
注意:示例里的ID与KEY为公共ID与KEY,共享每分钟调用频次限制,接口本身免费,请使用自己的ID与KEY,独享每分钟调用频次。每日调用无上限。

POST请求示例:
请根据开发语言自行POST。

返回数据示例:
示例:{"code":400,"msg":"通讯秘钥错误。"}
示例:
{
"code": 200,
"cnt": 40,
"name": "Haidian",
"country": "CN",
"sunrise": 1726523854,
"sunset": 1726568470,
"data": [{
"dt": 1726552800,
"time": "2024-09-17 06:00:00",
"temp": 300.91,
"pressure": 1006,
"humidity": 44,
"weather": "晴",
"clouds": 2,
"speed": 2.67,
"deg": 111,
"visibility": 10000
}, {
"dt": 1726563600,
"time": "2024-09-17 09:00:00",
"temp": 300.8,
"pressure": 1005,
"humidity": 49,
"weather": "多云",
"clouds": 63,
"speed": 3.25,
"deg": 110,
"visibility": 10000
}, {
"dt": 1726574400,
"time": "2024-09-17 12:00:00",
"temp": 299.28,
"pressure": 1007,
"humidity": 61,
"weather": "多云",
"clouds": 82,
"speed": 1.36,
"deg": 90,
"visibility": 10000
}, {
"dt": 1726585200,
"time": "2024-09-17 15:00:00",
"temp": 298.13,
"pressure": 1007,
"humidity": 68,
"weather": "多云",
"clouds": 57,
"speed": 1.6,
"deg": 123,
"visibility": 10000
}, {
"dt": 1726596000,
"time": "2024-09-17 18:00:00",
"temp": 296.68,
"pressure": 1007,
"humidity": 65,
"weather": "多云",
"clouds": 78,
"speed": 1.89,
"deg": 134,
"visibility": 10000
}, {
"dt": 1726606800,
"time": "2024-09-17 21:00:00",
"temp": 295.99,
"pressure": 1008,
"humidity": 59,
"weather": "阴,多云",
"clouds": 90,
"speed": 1.05,
"deg": 109,
"visibility": 10000
}, {
"dt": 1726617600,
"time": "2024-09-18 00:00:00",
"temp": 296.85,
"pressure": 1008,
"humidity": 53,
"weather": "阴,多云",
"clouds": 94,
"speed": 0.57,
"deg": 131,
"visibility": 10000
}, {
"dt": 1726628400,
"time": "2024-09-18 03:00:00",
"temp": 300.57,
"pressure": 1008,
"humidity": 36,
"weather": "多云",
"clouds": 56,
"speed": 1.47,
"deg": 132,
"visibility": 10000
}, {
"dt": 1726639200,
"time": "2024-09-18 06:00:00",
"temp": 303.11,
"pressure": 1006,
"humidity": 35,
"weather": "多云",
"clouds": 35,
"speed": 2.72,
"deg": 148,
"visibility": 10000
}, {
"dt": 1726650000,
"time": "2024-09-18 09:00:00",
"temp": 301.77,
"pressure": 1005,
"humidity": 47,
"weather": "晴,少云",
"clouds": 17,
"speed": 3.35,
"deg": 142,
"visibility": 10000
}, {
"dt": 1726660800,
"time": "2024-09-18 12:00:00",
"temp": 299.83,
"pressure": 1008,
"humidity": 52,
"weather": "多云",
"clouds": 51,
"speed": 2.04,
"deg": 169,
"visibility": 10000
}, {
"dt": 1726671600,
"time": "2024-09-18 15:00:00",
"temp": 298.71,
"pressure": 1008,
"humidity": 54,
"weather": "阴,多云",
"clouds": 99,
"speed": 1.86,
"deg": 148,
"visibility": 10000
}, {
"dt": 1726682400,
"time": "2024-09-18 18:00:00",
"temp": 297.77,
"pressure": 1008,
"humidity": 59,
"weather": "阴,多云",
"clouds": 100,
"speed": 2,
"deg": 149,
"visibility": 10000
}, {
"dt": 1726693200,
"time": "2024-09-18 21:00:00",
"temp": 296.87,
"pressure": 1007,
"humidity": 56,
"weather": "阴,多云",
"clouds": 100,
"speed": 1.49,
"deg": 120,
"visibility": 10000
}, {
"dt": 1726704000,
"time": "2024-09-19 00:00:00",
"temp": 297.41,
"pressure": 1007,
"humidity": 49,
"weather": "阴,多云",
"clouds": 98,
"speed": 1.36,
"deg": 145,
"visibility": 10000
}, {
"dt": 1726714800,
"time": "2024-09-19 03:00:00",
"temp": 298.78,
"pressure": 1006,
"humidity": 44,
"weather": "阴,多云",
"clouds": 87,
"speed": 2.98,
"deg": 154,
"visibility": 10000
}, {
"dt": 1726725600,
"time": "2024-09-19 06:00:00",
"temp": 298.78,
"pressure": 1004,
"humidity": 49,
"weather": "阴,多云",
"clouds": 87,
"speed": 1.82,
"deg": 139,
"visibility": 10000
}, {
"dt": 1726736400,
"time": "2024-09-19 09:00:00",
"temp": 299.42,
"pressure": 1002,
"humidity": 53,
"weather": "多云",
"clouds": 67,
"speed": 1.79,
"deg": 146,
"visibility": 10000
}, {
"dt": 1726747200,
"time": "2024-09-19 12:00:00",
"temp": 297.63,
"pressure": 1002,
"humidity": 64,
"weather": "多云",
"clouds": 64,
"speed": 1.33,
"deg": 131,
"visibility": 10000
}, {
"dt": 1726758000,
"time": "2024-09-19 15:00:00",
"temp": 295.82,
"pressure": 1004,
"humidity": 72,
"weather": "小雨",
"clouds": 56,
"speed": 2.34,
"deg": 351,
"visibility": 10000
}, {
"dt": 1726768800,
"time": "2024-09-19 18:00:00",
"temp": 293.06,
"pressure": 1005,
"humidity": 80,
"weather": "小雨",
"clouds": 78,
"speed": 3.87,
"deg": 326,
"visibility": 10000
}, {
"dt": 1726779600,
"time": "2024-09-19 21:00:00",
"temp": 291.2,
"pressure": 1007,
"humidity": 70,
"weather": "小雨",
"clouds": 100,
"speed": 4.8,
"deg": 343,
"visibility": 10000
}, {
"dt": 1726790400,
"time": "2024-09-20 00:00:00",
"temp": 291.25,
"pressure": 1010,
"humidity": 43,
"weather": "阴,多云",
"clouds": 100,
"speed": 5.12,
"deg": 349,
"visibility": 10000
}, {
"dt": 1726801200,
"time": "2024-09-20 03:00:00",
"temp": 292.49,
"pressure": 1012,
"humidity": 38,
"weather": "阴,多云",
"clouds": 100,
"speed": 4.67,
"deg": 337,
"visibility": 10000
}, {
"dt": 1726812000,
"time": "2024-09-20 06:00:00",
"temp": 297.66,
"pressure": 1011,
"humidity": 24,
"weather": "阴,多云",
"clouds": 99,
"speed": 4.74,
"deg": 345,
"visibility": 10000
}, {
"dt": 1726822800,
"time": "2024-09-20 09:00:00",
"temp": 297.3,
"pressure": 1012,
"humidity": 24,
"weather": "阴,多云",
"clouds": 100,
"speed": 3.78,
"deg": 43,
"visibility": 10000
}, {
"dt": 1726833600,
"time": "2024-09-20 12:00:00",
"temp": 295.28,
"pressure": 1014,
"humidity": 26,
"weather": "阴,多云",
"clouds": 100,
"speed": 2.32,
"deg": 25,
"visibility": 10000
}, {
"dt": 1726844400,
"time": "2024-09-20 15:00:00",
"temp": 292.56,
"pressure": 1015,
"humidity": 39,
"weather": "阴,多云",
"clouds": 90,
"speed": 1.8,
"deg": 219,
"visibility": 10000
}, {
"dt": 1726855200,
"time": "2024-09-20 18:00:00",
"temp": 291.31,
"pressure": 1014,
"humidity": 44,
"weather": "多云",
"clouds": 76,
"speed": 1,
"deg": 335,
"visibility": 10000
}, {
"dt": 1726866000,
"time": "2024-09-20 21:00:00",
"temp": 289.87,
"pressure": 1014,
"humidity": 45,
"weather": "晴",
"clouds": 0,
"speed": 1.62,
"deg": 351,
"visibility": 10000
}, {
"dt": 1726876800,
"time": "2024-09-21 00:00:00",
"temp": 291.12,
"pressure": 1014,
"humidity": 38,
"weather": "晴",
"clouds": 0,
"speed": 1.75,
"deg": 353,
"visibility": 10000
}, {
"dt": 1726887600,
"time": "2024-09-21 03:00:00",
"temp": 296.14,
"pressure": 1013,
"humidity": 27,
"weather": "晴",
"clouds": 0,
"speed": 1.35,
"deg": 30,
"visibility": 10000
}, {
"dt": 1726898400,
"time": "2024-09-21 06:00:00",
"temp": 299.23,
"pressure": 1010,
"humidity": 24,
"weather": "晴",
"clouds": 0,
"speed": 1.07,
"deg": 70,
"visibility": 10000
}, {
"dt": 1726909200,
"time": "2024-09-21 09:00:00",
"temp": 298.68,
"pressure": 1009,
"humidity": 23,
"weather": "晴",
"clouds": 0,
"speed": 1.89,
"deg": 127,
"visibility": 10000
}, {
"dt": 1726920000,
"time": "2024-09-21 12:00:00",
"temp": 295.3,
"pressure": 1010,
"humidity": 39,
"weather": "晴",
"clouds": 0,
"speed": 1.76,
"deg": 177,
"visibility": 10000
}, {
"dt": 1726930800,
"time": "2024-09-21 15:00:00",
"temp": 293.53,
"pressure": 1011,
"humidity": 45,
"weather": "晴",
"clouds": 0,
"speed": 1.64,
"deg": 351,
"visibility": 10000
}, {
"dt": 1726941600,
"time": "2024-09-21 18:00:00",
"temp": 291.42,
"pressure": 1011,
"humidity": 46,
"weather": "晴",
"clouds": 0,
"speed": 1.83,
"deg": 356,
"visibility": 10000
}, {
"dt": 1726952400,
"time": "2024-09-21 21:00:00",
"temp": 290.19,
"pressure": 1010,
"humidity": 48,
"weather": "晴",
"clouds": 0,
"speed": 1.94,
"deg": 346,
"visibility": 10000
}, {
"dt": 1726963200,
"time": "2024-09-22 00:00:00",
"temp": 291.67,
"pressure": 1012,
"humidity": 36,
"weather": "晴",
"clouds": 0,
"speed": 2.56,
"deg": 350,
"visibility": 10000
}, {
"dt": 1726974000,
"time": "2024-09-22 03:00:00",
"temp": 297.87,
"pressure": 1011,
"humidity": 20,
"weather": "晴",
"clouds": 0,
"speed": 2.25,
"deg": 358,
"visibility": 10000
}]
}

参考资料(版权):
https://www.apihz.cn/api/tianqitqybjw5.html

相关文章
|
14天前
|
API
国外地区经纬度查询免费API接口教程
此接口用于查询国外地区的经纬度信息,支持POST和GET请求方式。需提供用户ID、用户KEY、省级名称及具体地点。返回数据包括地区名称(中英文)、国家代码及经纬度等详细信息。示例请求与响应数据详见文档。
74 29
|
7月前
|
JSON JavaScript 前端开发
免费实时天气预报api接口
免费实时天气预报api接口
899 0
|
12天前
|
缓存 API
全球最新地震信息免费API接口教程
该接口提供全球最新地震信息,数据源自中国地震台网,每5分钟更新一次。支持POST/GET请求,需提供用户ID和KEY。返回数据包括地震等级、时间、经纬度、深度及位置等详细信息。示例请求和响应详见文档。
|
12天前
|
API
天气预报15日-墨迹天气-地址查询版免费API接口教程
该接口提供15日天气预报服务,通过指定地址获取墨迹天气预报。支持POST或GET请求,需提供用户ID、KEY、省份名称及地点等参数。返回数据包括15天内每天的天气详情,如最高最低温度、天气变化及图标等。示例中使用的ID和KEY为公共测试账号,建议使用个人账号以获得更高调用频率。
|
11天前
|
API
天气预报15日-墨迹天气-IP查询版免费API接口教程
该接口提供基于指定IP地址的15日天气预报,支持POST和GET请求方式。请求需包含用户ID、KEY,可选填IP地址,默认查询访问者IP所在地天气,查询失败时默认返回北京天气。返回值包括状态码、地点及15天天气详情,如星期、日历、天气状况、温度范围及天气图标等。示例请求和响应详见文档。
90 48
|
14天前
|
API
全国行政区划查询免费API接口教程
该接口提供全国(不含港澳台)各级行政区划查询服务,适用于地址填写、资料登记等场景。支持5级划分:省、市、区县、乡镇、村。请求需提供用户ID、KEY及查询级别等参数,返回地名列表或错误信息。 示例中ID和KEY为公共测试用,建议使用个人ID和KEY以享受更高调用频率。
72 23
|
11天前
|
API
全球天气预报1天-经纬度版免费API接口教程
该接口用于获取全球任意地区的天气信息,需提供经纬度参数。支持POST和GET请求,返回包括天气、气温、气压、湿度等详细信息。详情及示例参见API文档。
|
14天前
|
API
全国行政区划代码与经纬度查询免费API接口教程
该接口提供全国各行政区划代码及经纬度查询服务。通过POST或GET请求,输入用户ID、KEY及地点名称,可获取地区代码、省份、市级、区县级名称及经纬度等信息。示例URL:https://cn.apihz.cn/api/other/xzqhdm.php?id=88888888&key=88888888&sheng=北京&place=北京。返回数据包含状态码、信息提示及查询结果。
79 14
|
11天前
|
API
万年历[取当日信息]免费API接口教程
此API提供万年历当天的详细信息,包括农历、星期、宜忌、生肖、星座、节日、五行、星宿等。支持POST和GET请求,需提供用户ID和KEY。返回数据包含阳历、农历、干支、节日列表等多项内容。示例URL:https://cn.apihz.cn/api/time/getday.php?id=88888888&key=88888888。
62 10
|
13天前
|
API
天气预报1天-中国气象局-地址查询版免费API接口教程
此接口提供中国气象局官方的当日天气信息,支持POST和GET请求,需提供用户ID、KEY、省份及具体地点。返回数据包括状态码、消息、天气详情等。示例中使用的ID与KEY为公共测试用,建议使用个人ID与KEY以享受更高调用频次。