天气API接口数据, 数据字段最全,免费,稳定的实况天气预报接口
5分钟左右更新一次,支持全国3000多个市区县, 包含基本天气信息、24小时逐小时天气、气象预警列表、湿度、能见度、气压、降雨量、紫外线、风力风向风速、日出日落、空气质量、pm2.5、pm10、o3、no2、so2、是否需要带口罩、外出适宜、开窗适宜、是否需要打开净化器等等,可按地名、城市编号、IP查询、经纬度查询。
看上面的说明, 返回数据够多的吧, 该接口有每日免费次数, 付费最高可每日请求50万次
注意:本文档对接的是天气API的实况天气数据, 如需7日或更多请查看官网文档
接口特点
- 5分钟左右更新一次
- 支持全国所有市区县(3200个左右吧)
- 含24小时天气
- 含气象灾害预警
- 空气六因子
- 支持经纬度查询
- 多线路
对接流程
- 打开并注册天气API平台 (http://tianqiapi.com/) 进入用户中心,获取appid和appsecret
- 阅读实况天气开发文档
http://tianqiapi.com/index/doc?version=2030 - 请求接口
- 解析JSON
Tips:大家在请求这类三方http接口的时候, 请一定将接口地址设置在服务端, 为动态可修改的, 请勿在C端直连接口, 防止遇到网络问题导致程序异常。
请求接口 (appid和appsecret换成自己的)
https://v1.yiketianqi.com/free/v2030?appid=85841439&appsecret=EKCDLT4I&adcode=130200000000&aqi=
请求参数
参数名 | 必选 | 类型 | 说明 | 备注(示例) |
---|---|---|---|---|
appid | 是 | string | 用户appid | 先注册开发账号 |
appsecret | 是 | string | 用户appsecret | |
adcode | 否 | string | 国家统计局城市ID | 如:130200000000 请参考 全国统计用区划代码表 |
cityid | 否 | string | 城市ID | 请参考 城市ID列表 |
city | 否 | string | 城市名称 | 不要带市和区; 如: 青岛、铁西 |
province | 否 | string | 所在省 | 如果您担心city重名可传此参数, 不要带省和市; 如: 山东、上海 |
ip | 否 | string | IP地址 | 查询IP所在城市天气 |
lng | 否 | String | 经度 | 如: 119.545023 (需额外开通lbs权限) |
lat | 否 | String | 纬度 | 如: 36.044254 |
point | 否 | String | 坐标体系 | 默认百度坐标, 如使用高德坐标, 请传参: gaode |
callback | 否 | string | jsonp参数 | 如: jQuery.Callbacks |
vue | 否 | string | 跨域参数 | 如果您使用的是react、vue、angular请填写值: 1 |
hours | 否 | Int | 是否显示小时天气 | 默认隐藏, 如需显示, 请传参: 1 |
aqi | 否 | Int | 是否显示AQI六因子 | 默认隐藏, 如需显示, 请传参: 1 |
返回JSON内容
{"cityid": "101160602","date": "2024-02-25","week": "星期日","update_time": "22:55","city": "永昌","cityEn": "yongchang","country": "中国","countryEn": "China","wea": "阴","wea_img": "yin","tem": "-7.5","tem1": "-2","tem2": "-14","win": "东南风","win_speed": "2级","win_meter": "6km\/h","humidity": "94%",//湿度"visibility": "17km",//能见度"pressure": "792",//气压"air": "124",//空气质量"air_pm25": "124","air_level": "轻度污染","air_tips": "各类人群可多参加户外活动,多呼吸一下清新的空气。","alarm": [{"alarm_type": "道路结冰","alarm_level": "黄色","alarm_title": "甘肃省永昌县发布道路结冰黄色预警","alarm_content": "永昌县气象台2024年02月25日21时14分发布道路结冰黄色预警信号:受降雪和低温天气影响,预计未来24小时,我县大部乡镇将出现对交通有影响的道路结冰,请注意防范。(预警信息来源:国家预警信息发布中心)"},{"alarm_type": "道路结冰","alarm_level": "黄色","alarm_title": "甘肃省金昌市发布道路结冰黄色预警","alarm_content": "金昌市气象台2024年02月25日17时02分发布道路结冰黄色预警信号:受降雪和低温天气影响,预计未来24小时,我市部分路段将出现道路结冰,影响交通安全,请注意防范。(预警信息来源:国家预警信息发布中心)"}],"rain_pcpn": "0",//降雨量mm"uvIndex": "0",//紫外线0-11"uvDescription": "低","wea_day": "阴",//白天天气"wea_day_img": "yin","wea_night": "多云",//夜间天气"wea_night_img": "yun","sunrise": "07:50",//日出"sunset": "19:00",//日落"hours": [{"hours": "22:00","wea": "轻度雾霾","wea_img": "wu","tem": "-6","win": "东北风","win_speed": "1级","vis": "14.9",//能见度"aqinum": "114",//aqi"aqi": "轻度污染"},{"hours": "23:00","wea": "多云","wea_img": "yun","tem": "-6","win": "东南风","win_speed": "1级","vis": "78.06","aqinum": "52","aqi": "良"},{"hours": "00:00","wea": "多云","wea_img": "yun","tem": "-7","win": "东南风","win_speed": "无风","vis": "80.35","aqinum": "50","aqi": "优"},{"hours": "01:00","wea": "阴","wea_img": "yin","tem": "-7","win": "西南风","win_speed": "无风","vis": "82.84","aqinum": "48","aqi": "优"},{"hours": "02:00","wea": "阴","wea_img": "yin","tem": "-7","win": "西南风","win_speed": "无风","vis": "95.67","aqinum": "47","aqi": "优"},{"hours": "03:00","wea": "多云","wea_img": "yun","tem": "-7","win": "东风","win_speed": "1级","vis": "88.93","aqinum": "45","aqi": "优"},{"hours": "04:00","wea": "多云","wea_img": "yun","tem": "-8","win": "东北风","win_speed": "1级","vis": "86.09","aqinum": "44","aqi": "优"},{"hours": "05:00","wea": "多云","wea_img": "yun","tem": "-8","win": "风","win_speed": "1级","vis": "82.28","aqinum": "42","aqi": "优"},{"hours": "06:00","wea": "多云","wea_img": "yun","tem": "-8","win": "西北风","win_speed": "1级","vis": "85.25","aqinum": "41","aqi": "优"},{"hours": "07:00","wea": "晴","wea_img": "qing","tem": "-8","win": "西北风","win_speed": "2级","vis": "94.49","aqinum": "40","aqi": "优"},{"hours": "08:00","wea": "晴","wea_img": "qing","tem": "-8","win": "西北风","win_speed": "2级","vis": "103.71","aqinum": "40","aqi": "优"},{"hours": "09:00","wea": "晴","wea_img": "qing","tem": "-8","win": "西北风","win_speed": "2级","vis": "177.04","aqinum": "38","aqi": "优"},{"hours": "10:00","wea": "晴","wea_img": "qing","tem": "-7","win": "西北风","win_speed": "2级","vis": "231.08","aqinum": "37","aqi": "优"},{"hours": "11:00","wea": "晴","wea_img": "qing","tem": "-6","win": "西北风","win_speed": "2级","vis": "231.08","aqinum": "35","aqi": "优"},{"hours": "12:00","wea": "晴","wea_img": "qing","tem": "-5","win": "西北风","win_speed": "2级","vis": "231.08","aqinum": "32","aqi": "优"},{"hours": "13:00","wea": "多云","wea_img": "yun","tem": "-4","win": "西北风","win_speed": "1级","vis": "231.08","aqinum": "31","aqi": "优"},{"hours": "14:00","wea": "多云","wea_img": "yun","tem": "-3","win": "西北风","win_speed": "1级","vis": "231.08","aqinum": "30","aqi": "优"},{"hours": "15:00","wea": "多云","wea_img": "yun","tem": "-2","win": "东北风","win_speed": "2级","vis": "231.08","aqinum": "33","aqi": "优"},{"hours": "16:00","wea": "多云","wea_img": "yun","tem": "-1","win": "东北风","win_speed": "3级","vis": "231.08","aqinum": "27","aqi": "优"},{"hours": "17:00","wea": "多云","wea_img": "yun","tem": "-2","win": "东风","win_speed": "3级","vis": "231.08","aqinum": "25","aqi": "优"},{"hours": "18:00","wea": "多云","wea_img": "yun","tem": "-3","win": "东南风","win_speed": "3级","vis": "231.08","aqinum": "24","aqi": "优"},{"hours": "19:00","wea": "多云","wea_img": "yun","tem": "-5","win": "东风","win_speed": "3级","vis": "231.08","aqinum": "22","aqi": "优"},{"hours": "20:00","wea": "多云","wea_img": "yun","tem": "-6","win": "东风","win_speed": "2级","vis": "128.67","aqinum": "21","aqi": "优"},{"hours": "21:00","wea": "晴","wea_img": "qing","tem": "-6","win": "东北风","win_speed": "2级","vis": "120.35","aqinum": "21","aqi": "优"},{"hours": "22:00","wea": "晴","wea_img": "qing","tem": "-6","win": "东北风","win_speed": "2级","vis": "117.9","aqinum": "21","aqi": "优"},{"hours": "23:00","wea": "晴","wea_img": "qing","tem": "-7","win": "东风","win_speed": "1级","vis": "97.76","aqinum": "21","aqi": "优"},{"hours": "00:00","wea": "晴","wea_img": "qing","tem": "-7","win": "东北风","win_speed": "1级","vis": "90.18","aqinum": "21","aqi": "优"},{"hours": "01:00","wea": "晴","wea_img": "qing","tem": "-7","win": "风","win_speed": "1级","vis": "83.73","aqinum": "21","aqi": "优"}],"aqi": {"update_time": "22:30","air": "114","air_level": "轻度污染","air_tips": "各类人群可多参加户外活动,多呼吸一下清新的空气。","pm25": "86","pm25_desc": "轻度污染","pm10": "172","pm10_desc": "中度污染","o3": "80","o3_desc": "","no2": "20","no2_desc": "","so2": "6","so2_desc": "","co": "0.9","co_desc": "","kouzhao": "不用佩戴口罩","yundong": "适宜运动","waichu": "不适宜外出","kaichuang": "适宜开窗","jinghuaqi": "不需要打开"},"nums": 19
}