最近工作中遇到了天气预报功能,在网上搜寻了很多免费的API接口并做了测试,为了后期使用方便,整理汇总在此。
主要参考:https://developer.aliyun.com/article/848429;https://blog.csdn.net/weixin_44495599/article/details/121481336
目前主要有两个
官方文档:http://www.yytianqi.com/api.html
免费版主要支持
官方文档:http://www.weatherdt.com/
免费版主要支持:http://www.weatherdt.com/datadetail.html?code=9e3a049c-4b4b-4820-84bd-5ea8ae02e54d
本产品集免费提供5个国内城市7类常用气象数据作为试用,帮助用户了解数据结构及使用方式。5个城市包括:北京、上海、广州、深圳、重庆;数据种类为:3A以上景点实时天气实况数据、未来三天天气预报(逐12小时、24小时)、44种预警数据、未来7天日出日落、昨日天气、空气质量实况数据、日历农历节气数据。数据来源:与公共气象服务中心联合发布自研数据。
参考文档:https://www.sojson.com/api/weather.html
城市数据:
请看下面附件链接,点击下载不会乱码,打开有可能会乱码。
http://cdn.sojson.com/_city.json
老接口:http://t.weather.sojson.com/api/weather/city/101030100
新接口:http://t.weather.itboy.net/api/weather/city/101030100
经过测试,请求天津的天气链接为:http://t.weather.itboy.net/api/weather/city/101030100
返回成功状态(status)为:200 ,失败为非200
接口返回的天气指数数据很全面,如:温度、最高温度、最低温度、风、天气、空气质量指数。
参数只有一个,就是cityId,以前只要传城市名称,但是城市名称有N多重复的,为了精准和Cache命中率,采用了cityId,
{
"time": "2018-09-22 12:37:21",//系统更新时间
"cityInfo": {
"city": "天津市", //请求城市
"cityId": "101030100",//请求ID
"parent": "天津", //上级,一般是省份
"updateTime": "12:32"//天气更新时间
},
"date": "20180922", //当前天气的当天日期
"message": "Success !", //返回message
"status": 200, //返回状态
"data": {
"shidu": "22%", //湿度
"pm25": 15.0, //pm2.5
"pm10": 46.0, //pm10
"quality": "优", //空气质量
"wendu": "24", //温度
"ganmao": "各类人群可自由活动",//感冒提醒(指数)
"yesterday": { //昨天天气
"date": "21", //日 去掉了原来的 日字 + 星期,如 21日星期五 变成了21,星期和年月日在下面
"ymd": "2018-09-21", //年月日 (新增)
"week": "星期五", //星期 (新增)
"sunrise": "05:56", //日出
"high": "高温 25.0℃", //当天最高温
"low": "低温 15.0℃", //当天最低温
"sunset": "18:12", //日落
"aqi": 108.0, //空气指数
"fx": "西北风", //风向
"fl": "4-5级", //风力
"type": "晴", //天气
"notice": "愿你拥有比阳光明媚的心情"//天气描述
},
"forecast": [//今天+未来4天
{
"date": "22",
"ymd": "2018-09-22", //年月日 (新增)
"week": "星期六", //星期 (新增)
"sunrise": "05:57",
"high": "高温 26.0℃",
"low": "低温 15.0℃",
"sunset": "18:10",
"aqi": 55.0,
"fx": "西北风",
"fl": "4-5级",
"type": "晴",
"notice": "愿你拥有比阳光明媚的心情"
},
{
"date": "23",
"ymd": "2018-09-22", //年月日 (新增)
"week": "星期日", //星期 (新增)
"sunrise": "05:58",
"high": "高温 23.0℃",
"low": "低温 14.0℃",
"sunset": "18:09",
"aqi": 29.0,
"fx": "西北风",
"fl": "4-5级",
"type": "晴",
"notice": "愿你拥有比阳光明媚的心情"
},
{
"date": "24",
"ymd": "2018-09-22", //年月日 (新增)
"week": "星期一", //星期 (新增)
"sunrise": "05:59",
"high": "高温 24.0℃",
"low": "低温 15.0℃",
"sunset": "18:07",
"aqi": 25.0,
"fx": "西北风",
"fl": "<3级",
"type": "晴",
"notice": "愿你拥有比阳光明媚的心情"
},
{
"date": "25",
"ymd": "2018-09-22", //年月日 (新增)
"week": "星期二", //星期 (新增)
"sunrise": "06:00",
"high": "高温 24.0℃",
"low": "低温 16.0℃",
"sunset": "18:05",
"aqi": 56.0,
"fx": "西南风",
"fl": "<3级",
"type": "晴",
"notice": "愿你拥有比阳光明媚的心情"
},
{
"date": "26",
"ymd": "2018-09-22", //年月日 (新增)
"week": "星期三", //星期 (新增)
"sunrise": "06:01",
"high": "高温 24.0℃",
"low": "低温 17.0℃",
"sunset": "18:04",
"aqi": 86.0,
"fx": "西南风",
"fl": "3-4级",
"type": "阴",
"notice": "不要被阴云遮挡住好心情"
}
]
}
}
参考文档:https://blog.csdn.net/weixin_44495599/article/details/121481336
请求地址:http://d1.weather.com.cn/sk_2d/[1].html?_=[2]
请求方式:GET
Header:{“Referer”: “http://www.weather.com.cn/weather1d/[1].shtml”}
参数:
[1]:填写要查询城市的城市ID(见文末给出了全国所有地级市的ID信息;下同)
[2]:当前的毫秒级时间戳(目前随意传一个数字似乎就可以)
所有的城市id:
// An highlighted block
{
"北京": {
"北京": {
"AREAID": "101010100"
}
},
"上海": {
"上海": {
"AREAID": "101020100"
}
},
"天津": {
"天津": {
"AREAID": "101030100"
}
},
"重庆": {
"重庆": {
"AREAID": "101040100"
}
},
"黑龙江": {
"哈尔滨": {
"AREAID": "101050101"
},
"齐齐哈尔": {
"AREAID": "101050201"
},
"牡丹江": {
"AREAID": "101050301"
},
"佳木斯": {
"AREAID": "101050401"
},
"绥化": {
"AREAID": "101050501"
},
"黑河": {
"AREAID": "101050601"
},
"大兴安岭": {
"AREAID": "101050701"
},
"伊春": {
"AREAID": "101050801"
},
"大庆": {
"AREAID": "101050901"
},
"七台河": {
"AREAID": "101051002"
},
"鸡西": {
"AREAID": "101051101"
},
"鹤岗": {
"AREAID": "101051201"
},
"双鸭山": {
"AREAID": "101051301"
}
},
"吉林": {
"长春": {
"AREAID": "101060101"
},
"吉林": {
"AREAID": "101060201"
},
"延边": {
"AREAID": "101060306"
},
"四平": {
"AREAID": "101060401"
},
"通化": {
"AREAID": "101060501"
},
"白城": {
"AREAID": "101060601"
},
"辽源": {
"AREAID": "101060701"
},
"松原": {
"AREAID": "101060801"
},
"白山": {
"AREAID": "101060901"
}
},
"辽宁": {
"沈阳": {
"AREAID": "101070101"
},
"大连": {
"AREAID": "101070201"
},
"鞍山": {
"AREAID": "101070301"
},
"抚顺": {
"AREAID": "101070401"
},
"本溪": {
"AREAID": "101070501"
},
"丹东": {
"AREAID": "101070601"
},
"锦州": {
"AREAID": "101070701"
},
"营口": {
"AREAID": "101070801"
},
"阜新": {
"AREAID": "101070901"
},
"辽阳": {
"AREAID": "101071001"
},
"铁岭": {
"AREAID": "101071101"
},
"朝阳": {
"AREAID": "101071201"
},
"盘锦": {
"AREAID": "101071301"
},
"葫芦岛": {
"AREAID": "101071401"
}
},
"内蒙古": {
"呼和浩特": {
"AREAID": "101080101"
},
"包头": {
"AREAID": "101080201"
},
"乌海": {
"AREAID": "101080301"
},
"乌兰察布": {
"AREAID": "101080405"
},
"通辽": {
"AREAID": "101080501"
},
"赤峰": {
"AREAID": "101080601"
},
"鄂尔多斯": {
"AREAID": "101080701"
},
"巴彦淖尔": {
"AREAID": "101080811"
},
"锡林郭勒": {
"AREAID": "101080902"
},
"呼伦贝尔": {
"AREAID": "101081013"
},
"兴安盟": {
"AREAID": "101081108"
},
"阿拉善盟": {
"AREAID": "101081213"
}
},
"河北": {
"石家庄": {
"AREAID": "101090101"
},
"保定": {
"AREAID": "101090201"
},
"张家口": {
"AREAID": "101090301"
},
"承德": {
"AREAID": "101090402"
},
"唐山": {
"AREAID": "101090501"
},
"廊坊": {
"AREAID": "101090601"
},
"沧州": {
"AREAID": "101090701"
},
"衡水": {
"AREAID": "101090801"
},
"邢台": {
"AREAID": "101090901"
},
"邯郸": {
"AREAID": "101091001"
},
"秦皇岛": {
"AREAID": "101091101"
},
"雄安新区": {
"AREAID": "101091201"
}
},
"山西": {
"太原": {
"AREAID": "101100101"
},
"大同": {
"AREAID": "101100201"
},
"阳泉": {
"AREAID": "101100301"
},
"晋中": {
"AREAID": "101100401"
},
"长治": {
"AREAID": "101100501"
},
"晋城": {
"AREAID": "101100601"
},
"临汾": {
"AREAID": "101100701"
},
"运城": {
"AREAID": "101100801"
},
"朔州": {
"AREAID": "101100901"
},
"忻州": {
"AREAID": "101101001"
},
"吕梁": {
"AREAID": "101101100"
}
},
"陕西": {
"西安": {
"AREAID": "101110101"
},
"咸阳": {
"AREAID": "101110200"
},
"延安": {
"AREAID": "101110300"
},
"榆林": {
"AREAID": "101110401"
},
"渭南": {
"AREAID": "101110501"
},
"商洛": {
"AREAID": "101110601"
},
"安康": {
"AREAID": "101110701"
},
"汉中": {
"AREAID": "101110801"
},
"宝鸡": {
"AREAID": "101110901"
},
"铜川": {
"AREAID": "101111001"
},
"杨凌": {
"AREAID": "101111101"
}
},
"山东": {
"济南": {
"AREAID": "101120101"
},
"青岛": {
"AREAID": "101120201"
},
"淄博": {
"AREAID": "101120301"
},
"德州": {
"AREAID": "101120401"
},
"烟台": {
"AREAID": "101120501"
},
"潍坊": {
"AREAID": "101120601"
},
"济宁": {
"AREAID": "101120701"
},
"泰安": {
"AREAID": "101120801"
},
"临沂": {
"AREAID": "101120901"
},
"菏泽": {
"AREAID": "101121001"
},
"滨州": {
"AREAID": "101121101"
},
"东营": {
"AREAID": "101121201"
},
"威海": {
"AREAID": "101121301"
},
"枣庄": {
"AREAID": "101121401"
},
"日照": {
"AREAID": "101121501"
},
"莱芜": {
"AREAID": "101121601"
},
"聊城": {
"AREAID": "101121701"
}
},
"新疆": {
"乌鲁木齐": {
"AREAID": "101130101"
},
"克拉玛依": {
"AREAID": "101130201"
},
"石河子": {
"AREAID": "101130301"
},
"昌吉": {
"AREAID": "101130401"
},
"吐鲁番": {
"AREAID": "101130501"
},
"巴音郭楞": {
"AREAID": "101130609"
},
"阿拉尔": {
"AREAID": "101130701"
},
"阿克苏": {
"AREAID": "101130801"
},
"喀什": {
"AREAID": "101130901"
},
"伊犁": {
"AREAID": "101131012"
},
"塔城": {
"AREAID": "101131101"
},
"哈密": {
"AREAID": "101131201"
},
"和田": {
"AREAID": "101131301"
},
"阿勒泰": {
"AREAID": "101131401"
},
"克州": {
"AREAID": "101131505"
},
"博尔塔拉": {
"AREAID": "101131604"
},
"图木舒克": {
"AREAID": "101131701"
},
"五家渠": {
"AREAID": "101131801"
},
"铁门关": {
"AREAID": "101131901"
},
"昆玉": {
"AREAID": "101131920"
},
"北屯": {
"AREAID": "101132101"
},
"双河": {
"AREAID": "101132201"
},
"可克达拉": {
"AREAID": "101132301"
}
},
"西藏": {
"拉萨": {
"AREAID": "101140101"
},
"日喀则": {
"AREAID": "101140201"
},
"山南": {
"AREAID": "101140301"
},
"林芝": {
"AREAID": "101140401"
},
"昌都": {
"AREAID": "101140501"
},
"那曲": {
"AREAID": "101140601"
},
"阿里": {
"AREAID": "101140701"
}
},
"青海": {
"西宁": {
"AREAID": "101150101"
},
"海东": {
"AREAID": "101150207"
},
"黄南": {
"AREAID": "101150305"
},
"海南": {
"AREAID": "101150402"
},
"果洛": {
"AREAID": "101150507"
},
"玉树": {
"AREAID": "101150601"
},
"海西": {
"AREAID": "101150702"
},
"海北": {
"AREAID": "101150804"
}
},
"甘肃": {
"兰州": {
"AREAID": "101160101"
},
"定西": {
"AREAID": "101160201"
},
"平凉": {
"AREAID": "101160301"
},
"庆阳": {
"AREAID": "101160401"
},
"武威": {
"AREAID": "101160501"
},
"金昌": {
"AREAID": "101160601"
},
"张掖": {
"AREAID": "101160701"
},
"酒泉": {
"AREAID": "101160801"
},
"天水": {
"AREAID": "101160901"
},
"陇南": {
"AREAID": "101161010"
},
"临夏": {
"AREAID": "101161101"
},
"甘南": {
"AREAID": "101161209"
},
"白银": {
"AREAID": "101161301"
},
"嘉峪关": {
"AREAID": "101161401"
}
},
"宁夏": {
"银川": {
"AREAID": "101170101"
},
"石嘴山": {
"AREAID": "101170201"
},
"吴忠": {
"AREAID": "101170301"
},
"固原": {
"AREAID": "101170401"
},
"中卫": {
"AREAID": "101170501"
}
},
"河南": {
"郑州": {
"AREAID": "101180101"
},
"安阳": {
"AREAID": "101180201"
},
"新乡": {
"AREAID": "101180301"
},
"许昌": {
"AREAID": "101180401"
},
"平顶山": {
"AREAID": "101180501"
},
"信阳": {
"AREAID": "101180601"
},
"南阳": {
"AREAID": "101180701"
},
"开封": {
"AREAID": "101180801"
},
"洛阳": {
"AREAID": "101180901"
},
"商丘": {
"AREAID": "101181001"
},
"焦作": {
"AREAID": "101181101"
},
"鹤壁": {
"AREAID": "101181201"
},
"濮阳": {
"AREAID": "101181301"
},
"周口": {
"AREAID": "101181401"
},
"漯河": {
"AREAID": "101181501"
},
"驻马店": {
"AREAID": "101181601"
},
"三门峡": {
"AREAID": "101181701"
},
"济源": {
"AREAID": "101181801"
}
},
"江苏": {
"南京": {
"AREAID": "101190101"
},
"无锡": {
"AREAID": "101190201"
},
"镇江": {
"AREAID": "101190301"
},
"苏州": {
"AREAID": "101190401"
},
"南通": {
"AREAID": "101190501"
},
"扬州": {
"AREAID": "101190601"
},
"盐城": {
"AREAID": "101190701"
},
"徐州": {
"AREAID": "101190801"
},
"淮安": {
"AREAID": "101190901"
},
"连云港": {
"AREAID": "101191001"
},
"常州": {
"AREAID": "101191101"
},
"泰州": {
"AREAID": "101191201"
},
"宿迁": {
"AREAID": "101191301"
}
},
"湖北": {
"武汉": {
"AREAID": "101200101"
},
"襄阳": {
"AREAID": "101200201"
},
"鄂州": {
"AREAID": "101200301"
},
"孝感": {
"AREAID": "101200401"
},
"黄冈": {
"AREAID": "101200501"
},
"黄石": {
"AREAID": "101200601"
},
"咸宁": {
"AREAID": "101200701"
},
"荆州": {
"AREAID": "101200801"
},
"宜昌": {
"AREAID": "101200901"
},
"恩施": {
"AREAID": "101201001"
},
"十堰": {
"AREAID": "101201101"
},
"神农架": {
"AREAID": "101201201"
},
"随州": {
"AREAID": "101201301"
},
"荆门": {
"AREAID": "101201401"
},
"天门": {
"AREAID": "101201501"
},
"仙桃": {
"AREAID": "101201601"
},
"潜江": {
"AREAID": "101201701"
}
},
"浙江": {
"杭州": {
"AREAID": "101210101"
},
"湖州": {
"AREAID": "101210201"
},
"嘉兴": {
"AREAID": "101210301"
},
"宁波": {
"AREAID": "101210401"
},
"绍兴": {
"AREAID": "101210507"
},
"台州": {
"AREAID": "101210601"
},
"温州": {
"AREAID": "101210701"
},
"丽水": {
"AREAID": "101210801"
},
"金华": {
"AREAID": "101210901"
},
"衢州": {
"AREAID": "101211001"
},
"舟山": {
"AREAID": "101211101"
}
},
"安徽": {
"合肥": {
"AREAID": "101220101"
},
"蚌埠": {
"AREAID": "101220201"
},
"芜湖": {
"AREAID": "101220301"
},
"淮南": {
"AREAID": "101220401"
},
"马鞍山": {
"AREAID": "101220501"
},
"安庆": {
"AREAID": "101220601"
},
"宿州": {
"AREAID": "101220701"
},
"阜阳": {
"AREAID": "101220801"
},
"亳州": {
"AREAID": "101220901"
},
"黄山": {
"AREAID": "101221001"
},
"滁州": {
"AREAID": "101221101"
},
"淮北": {
"AREAID": "101221201"
},
"铜陵": {
"AREAID": "101221301"
},
"宣城": {
"AREAID": "101221401"
},
"六安": {
"AREAID": "101221501"
},
"池州": {
"AREAID": "101221701"
}
},
"福建": {
"福州": {
"AREAID": "101230101"
},
"厦门": {
"AREAID": "101230201"
},
"宁德": {
"AREAID": "101230301"
},
"莆田": {
"AREAID": "101230401"
},
"泉州": {
"AREAID": "101230501"
},
"漳州": {
"AREAID": "101230601"
},
"龙岩": {
"AREAID": "101230701"
},
"三明": {
"AREAID": "101230801"
},
"南平": {
"AREAID": "101230901"
},
"钓鱼岛": {
"AREAID": "101231001"
}
},
"江西": {
"南昌": {
"AREAID": "101240101"
},
"九江": {
"AREAID": "101240201"
},
"上饶": {
"AREAID": "101240301"
},
"抚州": {
"AREAID": "101240401"
},
"宜春": {
"AREAID": "101240501"
},
"吉安": {
"AREAID": "101240601"
},
"赣州": {
"AREAID": "101240701"
},
"景德镇": {
"AREAID": "101240801"
},
"萍乡": {
"AREAID": "101240901"
},
"新余": {
"AREAID": "101241001"
},
"鹰潭": {
"AREAID": "101241101"
}
},
"湖南": {
"长沙": {
"AREAID": "101250101"
},
"湘潭": {
"AREAID": "101250201"
},
"株洲": {
"AREAID": "101250301"
},
"衡阳": {
"AREAID": "101250401"
},
"郴州": {
"AREAID": "101250501"
},
"常德": {
"AREAID": "101250601"
},
"益阳": {
"AREAID": "101250700"
},
"娄底": {
"AREAID": "101250801"
},
"邵阳": {
"AREAID": "101250901"
},
"岳阳": {
"AREAID": "101251001"
},
"张家界": {
"AREAID": "101251101"
},
"怀化": {
"AREAID": "101251201"
},
"永州": {
"AREAID": "101251401"
},
"湘西": {
"AREAID": "101251509"
}
},
"贵州": {
"贵阳": {
"AREAID": "101260101"
},
"遵义": {
"AREAID": "101260201"
},
"安顺": {
"AREAID": "101260301"
},
"黔南": {
"AREAID": "101260413"
},
"黔东南": {
"AREAID": "101260506"
},
"铜仁": {
"AREAID": "101260601"
},
"毕节": {
"AREAID": "101260701"
},
"六盘水": {
"AREAID": "101260803"
},
"黔西南": {
"AREAID": "101260906"
}
},
"四川": {
"成都": {
"AREAID": "101270101"
},
"攀枝花": {
"AREAID": "101270201"
},
"自贡": {
"AREAID": "101270301"
},
"绵阳": {
"AREAID": "101270401"
},
"南充": {
"AREAID": "101270501"
},
"达州": {
"AREAID": "101270601"
},
"遂宁": {
"AREAID": "101270701"
},
"广安": {
"AREAID": "101270801"
},
"巴中": {
"AREAID": "101270901"
},
"泸州": {
"AREAID": "101271001"
},
"宜宾": {
"AREAID": "101271101"
},
"内江": {
"AREAID": "101271201"
},
"资阳": {
"AREAID": "101271301"
},
"乐山": {
"AREAID": "101271401"
},
"眉山": {
"AREAID": "101271501"
},
"凉山": {
"AREAID": "101271601"
},
"雅安": {
"AREAID": "101271701"
},
"甘孜": {
"AREAID": "101271801"
},
"阿坝": {
"AREAID": "101271901"
},
"德阳": {
"AREAID": "101272001"
},
"广元": {
"AREAID": "101272101"
}
},
"广东": {
"广州": {
"AREAID": "101280101"
},
"韶关": {
"AREAID": "101280201"
},
"惠州": {
"AREAID": "101280301"
},
"梅州": {
"AREAID": "101280401"
},
"汕头": {
"AREAID": "101280501"
},
"深圳": {
"AREAID": "101280601"
},
"珠海": {
"AREAID": "101280701"
},
"佛山": {
"AREAID": "101280800"
},
"肇庆": {
"AREAID": "101280901"
},
"湛江": {
"AREAID": "101281001"
},
"江门": {
"AREAID": "101281101"
},
"河源": {
"AREAID": "101281201"
},
"清远": {
"AREAID": "101281301"
},
"云浮": {
"AREAID": "101281401"
},
"潮州": {
"AREAID": "101281501"
},
"东莞": {
"AREAID": "101281601"
},
"中山": {
"AREAID": "101281701"
},
"阳江": {
"AREAID": "101281801"
},
"揭阳": {
"AREAID": "101281901"
},
"茂名": {
"AREAID": "101282001"
},
"汕尾": {
"AREAID": "101282101"
}
},
"云南": {
"昆明": {
"AREAID": "101290101"
},
"大理": {
"AREAID": "101290201"
},
"红河": {
"AREAID": "101290301"
},
"曲靖": {
"AREAID": "101290401"
},
"保山": {
"AREAID": "101290501"
},
"文山": {
"AREAID": "101290601"
},
"玉溪": {
"AREAID": "101290701"
},
"楚雄": {
"AREAID": "101290801"
},
"普洱": {
"AREAID": "101290901"
},
"昭通": {
"AREAID": "101291001"
},
"临沧": {
"AREAID": "101291101"
},
"怒江": {
"AREAID": "101291201"
},
"迪庆": {
"AREAID": "101291305"
},
"丽江": {
"AREAID": "101291401"
},
"德宏": {
"AREAID": "101291501"
},
"西双版纳": {
"AREAID": "101291602"
}
},
"广西": {
"南宁": {
"AREAID": "101300101"
},
"崇左": {
"AREAID": "101300201"
},
"柳州": {
"AREAID": "101300301"
},
"来宾": {
"AREAID": "101300401"
},
"桂林": {
"AREAID": "101300501"
},
"梧州": {
"AREAID": "101300601"
},
"贺州": {
"AREAID": "101300701"
},
"贵港": {
"AREAID": "101300801"
},
"玉林": {
"AREAID": "101300901"
},
"百色": {
"AREAID": "101301001"
},
"钦州": {
"AREAID": "101301101"
},
"河池": {
"AREAID": "101301201"
},
"北海": {
"AREAID": "101301301"
},
"防城港": {
"AREAID": "101301401"
}
},
"海南": {
"海口": {
"AREAID": "101310101"
},
"三亚": {
"AREAID": "101310201"
},
"东方": {
"AREAID": "101310202"
},
"临高": {
"AREAID": "101310203"
},
"澄迈": {
"AREAID": "101310204"
},
"儋州": {
"AREAID": "101310205"
},
"昌江": {
"AREAID": "101310206"
},
"白沙": {
"AREAID": "101310207"
},
"琼中": {
"AREAID": "101310208"
},
"定安": {
"AREAID": "101310209"
},
"屯昌": {
"AREAID": "101310210"
},
"琼海": {
"AREAID": "101310211"
},
"文昌": {
"AREAID": "101310212"
},
"保亭": {
"AREAID": "101310214"
},
"万宁": {
"AREAID": "101310215"
},
"陵水": {
"AREAID": "101310216"
},
"乐东": {
"AREAID": "101310221"
},
"五指山": {
"AREAID": "101310222"
},
"三沙": {
"AREAID": "101310301"
}
},
"香港": {
"香港": {
"AREAID": "101320101"
}
},
"澳门": {
"澳门": {
"AREAID": "101330101"
}
},
"台湾": {
"台北": {
"AREAID": "101340101"
},
"高雄": {
"AREAID": "101340201"
},
"台中": {
"AREAID": "101340401"
}
}
}
接口url:
http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&clientType=android&sign=android&city=上海&latitude=39.902895&longitude=116.427915&needMoreData=true&pageNo=1&pageSize=7
注:支持通过城市名直接查询或者通过经纬度查询,city和经纬度经过一种方式即可。
返回数据为json格式;
支持未来7天的数据查询,支持的数据有天气、温度、湿度、PM2.5、PM10、空气指数、空气质量、日出时间、日落时间等;
例如查询上海数据:http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&clientType=android&sign=android&city=上海&needMoreData=true&pageNo=1&pageSize=7
pageSize参数 可以根据需要选择1-7;
{
"code": 0,
"msg": "操作成功",
"data": {
"total": 7,
"sourceName": "墨迹天气",
"list": [
{
"city": "上海",
"lastUpdateTime": "2022-06-08 16:55:08",
"date": "2022-06-08",
"weather": "多云",
"temp": 27.0,
"humidity": "42%",
"wind": "西风2级",
"pm25": 19.0,
"pm10": 25.0,
"low": 20.0,
"high": 28.0,
"airData": "43",
"airQuality": "优",
"dateLong": 1654617600000,
"weatherType": 1,
"windLevel": 2,
"province": "上海",
"moreData": {
"sunrise": "2022-06-08 04:50:00",
"sunset": "2022-06-08 18:57:00",
"precipitation": "0",
"alert": null
}
},
{
"city": "上海",
"lastUpdateTime": "2022-06-08 16:09:00",
"date": "2022-06-09",
"weather": "晴",
"humidity": "未知",
"wind": "南风",
"pm25": 0.0,
"low": 20.0,
"high": 25.0,
"airData": "59",
"airQuality": "良",
"dateLong": 1654704000000,
"weatherType": 0,
"windLevel": 3,
"province": "上海",
"moreData": {
"sunrise": "2022-06-09 04:49:00",
"sunset": "2022-06-09 18:57:00",
"precipitation": null,
"alert": null
}
},
{
"city": "上海",
"lastUpdateTime": "2022-06-08 16:09:00",
"date": "2022-06-10",
"weather": "大雨",
"humidity": "未知",
"wind": "东南风",
"pm25": 0.0,
"low": 20.0,
"high": 22.0,
"airData": "46",
"airQuality": "优",
"dateLong": 1654790400000,
"weatherType": 9,
"windLevel": 3,
"province": "上海",
"moreData": {
"sunrise": "2022-06-10 04:49:00",
"sunset": "2022-06-10 18:58:00",
"precipitation": null,
"alert": null
}
},
{
"city": "上海",
"lastUpdateTime": "2022-06-08 16:09:00",
"date": "2022-06-11",
"weather": "多云",
"humidity": "未知",
"wind": "东风",
"pm25": 0.0,
"low": 20.0,
"high": 26.0,
"airData": "49",
"airQuality": "优",
"dateLong": 1654876800000,
"weatherType": 1,
"windLevel": 3,
"province": "上海",
"moreData": {
"sunrise": "2022-06-11 04:49:00",
"sunset": "2022-06-11 18:58:00",
"precipitation": null,
"alert": null
}
},
{
"city": "上海",
"lastUpdateTime": "2022-06-08 16:09:00",
"date": "2022-06-12",
"weather": "小雨",
"humidity": "未知",
"wind": "东南风",
"pm25": 0.0,
"low": 20.0,
"high": 26.0,
"airData": "52",
"airQuality": "良",
"dateLong": 1654963200000,
"weatherType": 7,
"windLevel": 3,
"province": "上海",
"moreData": {
"sunrise": "2022-06-12 04:49:00",
"sunset": "2022-06-12 18:58:00",
"precipitation": null,
"alert": null
}
},
{
"city": "上海",
"lastUpdateTime": "2022-06-08 16:09:00",
"date": "2022-06-13",
"weather": "小雨",
"humidity": "未知",
"wind": "东风",
"pm25": 0.0,
"low": 20.0,
"high": 27.0,
"airData": "46",
"airQuality": "优",
"dateLong": 1655049600000,
"weatherType": 7,
"windLevel": 3,
"province": "上海",
"moreData": {
"sunrise": "2022-06-13 04:49:00",
"sunset": "2022-06-13 18:59:00",
"precipitation": null,
"alert": null
}
},
{
"city": "上海",
"lastUpdateTime": "2022-06-08 16:09:00",
"date": "2022-06-14",
"weather": "阴",
"humidity": "未知",
"wind": "东南风",
"pm25": 0.0,
"low": 21.0,
"high": 26.0,
"airQuality": "未知",
"dateLong": 1655136000000,
"weatherType": 2,
"windLevel": 4,
"province": "上海",
"moreData": {
"sunrise": "2022-06-14 04:50:00",
"sunset": "2022-06-14 18:59:00",
"precipitation": null,
"alert": null
}
}
],
"logoUrl": "http://iflycar.hfdn.openstorage.cn/xfypicture/dev/logo/moji.png"
}
}
该类型很多。推荐次序,免费天气API,和风天气,高德地图,心知天气,不推荐国外的,国外测试没通过
参考:https://developer.aliyun.com/article/848429
包含基本天气、温度、风力风向、空气质量、气压、湿度等,可按地名、城市编号、IP查询。
支持最多30个城市ID同时查询。
具体参见:
https://www.tianqiapi.com/index/doc?version=day
接口举例:
https://www.tianqiapi.com/api?version=v6&appid=21375891&appsecret=fTYv7v5E&city=南京
{
"cityid": "101190101",
"date": "2020-09-16",
"week": "星期三",
"update_time": "2020-09-16 09:49:03",
"city": "南京",
"cityEn": "nanjing",
"country": "中国",
"countryEn": "China",
"wea": "多云",
"wea_img": "yun",
"tem": "25",
"tem1": "28",
"tem2": "22",
"win": "西北风",
"win_speed": "1级",
"win_meter": "小于12km/h",
"humidity": "87%",
"visibility": "9.03km",
"pressure": "1006",
"air": "25",
"air_pm25": "25",
"air_level": "优",
"air_tips": "空气很好,可以外出活动,呼吸新鲜空气,拥抱大自然!",
"alarm": {
"alarm_type": "",
"alarm_level": "",
"alarm_content": ""
}
}
包含基本天气、温度、风力风向等,可按地名、城市编号、IP查询。
支持最多30个城市ID同时查询。
具体参见:
https://www.tianqiapi.com/index/doc?version=week
接口举例:
https://www.tianqiapi.com/api?version=v1&appid=21375891&appsecret=fTYv7v5E&city=福州
{
"cityid": "101230101",
"update_time": "2020-09-16 10:01:37",
"city": "福州",
"cityEn": "fuzhou",
"country": "中国",
"countryEn": "China",
"data": [
{
"day": "16日(今天)",
"date": "2020-09-16",
"week": "星期三",
"wea": "多云转阴",
"wea_img": "yun",
"air": 54,
"humidity": 69,
"air_level": "良",
"air_tips": "空气好,可以外出活动,除极少数对污染物特别敏感的人群以外,对公众没有危害!",
"alarm": {
"alarm_type": "",
"alarm_level": "",
"alarm_content": ""
},
"tem1": "35℃",
"tem2": "26℃",
"tem": "27℃",
"win": [
"无持续风向",
"无持续风向"
],
"win_speed": "<3级",
"hours": [
{
"day": "16日08时",
"wea": "阴",
"tem": "27℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "16日11时",
"wea": "多云",
"tem": "33℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "16日14时",
"wea": "多云",
"tem": "34℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "16日17时",
"wea": "多云",
"tem": "32℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "16日20时",
"wea": "多云",
"tem": "29℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "16日23时",
"wea": "阴",
"tem": "27℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "17日02时",
"wea": "阴",
"tem": "26℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "17日05时",
"wea": "阴",
"tem": "26℃",
"win": "无持续风向",
"win_speed": "<3级"
}
],
"index": [
{
"title": "中国人民保险
中暑指数",
"level": "可能中暑",
"desc": "中暑等级不高,但体质较弱者可能中暑,注意适时通风,保证环境温度舒适。"
},
{
"title": "",
"level": null,
"desc": "天气有点热,运动多补水。"
},
{
"title": "健臻·血糖指数",
"level": "易波动",
"desc": "血糖易波动,注意监测。"
},
{
"title": "穿衣指数",
"level": "炎热",
"desc": "建议穿短衫、短裤等清凉夏季服装。"
},
{
"title": "洗车指数",
"level": "适宜",
"desc": "天气较好,适合擦洗汽车。"
},
{
"title": "紫外线指数",
"level": "中等",
"desc": "涂擦SPF大于15、PA+防晒护肤品。"
}
]
},
{
"day": "17日(明天)",
"date": "2020-09-17",
"week": "星期四",
"wea": "多云",
"wea_img": "yun",
"tem1": "36℃",
"tem2": "27℃",
"tem": "27℃",
"win": [
"无持续风向",
"无持续风向"
],
"win_speed": "<3级",
"hours": [
{
"day": "17日08时",
"wea": "阴",
"tem": "27℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "17日11时",
"wea": "多云",
"tem": "33℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "17日14时",
"wea": "多云",
"tem": "35℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "17日17时",
"wea": "多云",
"tem": "33℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "17日20时",
"wea": "多云",
"tem": "30℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "17日23时",
"wea": "多云",
"tem": "30℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "18日02时",
"wea": "多云",
"tem": "29℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "18日05时",
"wea": "多云",
"tem": "27℃",
"win": "无持续风向",
"win_speed": "<3级"
}
],
"index": [
{
"title": "中国人民保险
中暑指数",
"level": "较易中暑",
"desc": "暑气灼人,户外工作要避免长时间在阳光下曝晒。"
},
{
"title": "",
"level": null,
"desc": "天气有点热,运动多补水。"
},
{
"title": "健臻·血糖指数",
"level": "易波动",
"desc": "气温高,血糖易波动,注意防暑降温。"
},
{
"title": "穿衣指数",
"level": "炎热",
"desc": "建议穿短衫、短裤等清凉夏季服装。"
},
{
"title": "洗车指数",
"level": "较适宜",
"desc": "无雨且风力较小,易保持清洁度。"
},
{
"title": "紫外线指数",
"level": "中等",
"desc": "涂擦SPF大于15、PA+防晒护肤品。"
}
]
},
{
"day": "18日(后天)",
"date": "2020-09-18",
"week": "星期五",
"wea": "中雨转小雨",
"wea_img": "yu",
"tem1": "33℃",
"tem2": "25℃",
"tem": "28℃",
"win": [
"东风",
"无持续风向"
],
"win_speed": "3-4级转<3级",
"hours": [
{
"day": "18日08时",
"wea": "晴",
"tem": "28℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "18日11时",
"wea": "中雨",
"tem": "32℃",
"win": "东风",
"win_speed": "<3级"
},
{
"day": "18日14时",
"wea": "中雨",
"tem": "32℃",
"win": "东风",
"win_speed": "3-4级"
},
{
"day": "18日17时",
"wea": "小雨",
"tem": "29℃",
"win": "东风",
"win_speed": "3-4级"
},
{
"day": "18日20时",
"wea": "阴",
"tem": "27℃",
"win": "东风",
"win_speed": "3-4级"
},
{
"day": "18日23时",
"wea": "阴",
"tem": "26℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "19日02时",
"wea": "小雨",
"tem": "26℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "19日05时",
"wea": "小雨",
"tem": "25℃",
"win": "无持续风向",
"win_speed": "<3级"
}
],
"index": [
{
"title": "中国人民保险
中暑指数",
"level": "可能中暑",
"desc": "对敏感人群来说,今天可能出现中暑的情况,出门时该做的防护还是做起来吧~"
},
{
"title": "",
"level": null,
"desc": "天气闷热,坚持室内低强度运动。"
},
{
"title": "健臻·血糖指数",
"level": "易波动",
"desc": "血糖易波动,注意监测。"
},
{
"title": "穿衣指数",
"level": "炎热",
"desc": "建议穿短衫、短裤等清凉夏季服装。"
},
{
"title": "洗车指数",
"level": "不宜",
"desc": "有雨,雨水和泥水会弄脏爱车。"
},
{
"title": "紫外线指数",
"level": "最弱",
"desc": "辐射弱,涂擦SPF8-12防晒护肤品。"
}
]
},
{
"day": "19日(周六)",
"date": "2020-09-19",
"week": "星期六",
"wea": "小雨",
"wea_img": "yu",
"tem1": "29℃",
"tem2": "25℃",
"tem": "25℃",
"win": [
"无持续风向",
"无持续风向"
],
"win_speed": "<3级",
"hours": [
{
"day": "19日08时",
"wea": "阴",
"tem": "25℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "19日14时",
"wea": "阴",
"tem": "28℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "19日20时",
"wea": "小雨",
"tem": "27℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "20日02时",
"wea": "小雨",
"tem": "25℃",
"win": "无持续风向",
"win_speed": "<3级"
}
],
"index": [
{
"title": "中国人民保险
中暑指数",
"level": "无中暑风险",
"desc": "天气不热,在炎炎夏日中十分难得,可以告别暑气漫漫啦~"
},
{
"title": "",
"level": null,
"desc": "春天快来了,雨天坚持室内运动吧。"
},
{
"title": "健臻·血糖指数",
"level": "易波动",
"desc": "气温多变,血糖易波动,请注意监测。"
},
{
"title": "穿衣指数",
"level": "热",
"desc": "适合穿T恤、短薄外套等夏季服装。"
},
{
"title": "洗车指数",
"level": "不宜",
"desc": "有雨,雨水和泥水会弄脏爱车。"
},
{
"title": "紫外线指数",
"level": "最弱",
"desc": "辐射弱,涂擦SPF8-12防晒护肤品。"
}
]
},
{
"day": "20日(周日)",
"date": "2020-09-20",
"week": "星期日",
"wea": "小雨转多云",
"wea_img": "yun",
"tem1": "28℃",
"tem2": "23℃",
"tem": "25℃",
"win": [
"无持续风向",
"无持续风向"
],
"win_speed": "<3级",
"hours": [
{
"day": "20日08时",
"wea": "小雨",
"tem": "25℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "20日14时",
"wea": "小雨",
"tem": "27℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "20日20时",
"wea": "小雨",
"tem": "24℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "21日02时",
"wea": "多云",
"tem": "23℃",
"win": "无持续风向",
"win_speed": "<3级"
}
],
"index": [
{
"title": "中国人民保险
中暑指数",
"level": "无中暑风险",
"desc": "天气舒适,对易中暑人群来说非常友善。"
},
{
"title": "",
"level": null,
"desc": "春天快来了,雨天坚持室内运动吧。"
},
{
"title": "健臻·血糖指数",
"level": "不易波动",
"desc": "天气条件不易引起血糖波动。"
},
{
"title": "穿衣指数",
"level": "热",
"desc": "适合穿T恤、短薄外套等夏季服装。"
},
{
"title": "洗车指数",
"level": "不宜",
"desc": "有雨,雨水和泥水会弄脏爱车。"
},
{
"title": "紫外线指数",
"level": "最弱",
"desc": "辐射弱,涂擦SPF8-12防晒护肤品。"
}
]
},
{
"day": "21日(周一)",
"date": "2020-09-21",
"week": "星期一",
"wea": "多云",
"wea_img": "yun",
"tem1": "28℃",
"tem2": "23℃",
"tem": "24℃",
"win": [
"东风",
"无持续风向"
],
"win_speed": "3-4级转<3级",
"hours": [
{
"day": "21日08时",
"wea": "多云",
"tem": "24℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "21日14时",
"wea": "多云",
"tem": "27℃",
"win": "东风",
"win_speed": "3-4级"
},
{
"day": "21日20时",
"wea": "多云",
"tem": "25℃",
"win": "东风",
"win_speed": "<3级"
},
{
"day": "22日02时",
"wea": "多云",
"tem": "23℃",
"win": "无持续风向",
"win_speed": "<3级"
}
],
"index": [
{
"title": "中国人民保险
中暑指数",
"level": "无中暑风险",
"desc": "天气舒适,对易中暑人群来说非常友善。"
},
{
"title": "",
"level": null,
"desc": "春天不减肥,夏天徒伤悲。风虽有点大,室内可健身。"
},
{
"title": "健臻·血糖指数",
"level": "不易波动",
"desc": "天气条件好,血糖不易波动,可适时进行户外锻炼。"
},
{
"title": "穿衣指数",
"level": "热",
"desc": "适合穿T恤、短薄外套等夏季服装。"
},
{
"title": "洗车指数",
"level": "较适宜",
"desc": "无雨且风力较小,易保持清洁度。"
},
{
"title": "紫外线指数",
"level": "中等",
"desc": "涂擦SPF大于15、PA+防晒护肤品。"
}
]
},
{
"day": "22日(周二)",
"date": "2020-09-22",
"week": "星期二",
"wea": "阴转多云",
"wea_img": "yun",
"tem1": "29℃",
"tem2": "23℃",
"tem": "23℃",
"win": [
"无持续风向",
"无持续风向"
],
"win_speed": "<3级",
"hours": [
{
"day": "22日08时",
"wea": "多云",
"tem": "23℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "22日14时",
"wea": "阴",
"tem": "28℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "22日20时",
"wea": "阴",
"tem": "26℃",
"win": "无持续风向",
"win_speed": "<3级"
},
{
"day": "23日02时",
"wea": "多云",
"tem": "23℃",
"win": "无持续风向",
"win_speed": "<3级"
}
],
"index": [
{
"title": "中国人民保险
中暑指数",
"level": "无中暑风险",
"desc": "天气不热,在炎炎夏日中十分难得,可以告别暑气漫漫啦~"
},
{
"title": "",
"level": null,
"desc": "春天不减肥,夏天徒伤悲。天气较舒适,快去运动吧。"
},
{
"title": "健臻·血糖指数",
"level": "不易波动",
"desc": "天气条件好,血糖不易波动,可适时进行户外锻炼。"
},
{
"title": "穿衣指数",
"level": "热",
"desc": "适合穿T恤、短薄外套等夏季服装。"
},
{
"title": "洗车指数",
"level": "较适宜",
"desc": "无雨且风力较小,易保持清洁度。"
},
{
"title": "紫外线指数",
"level": "最弱",
"desc": "辐射弱,涂擦SPF8-12防晒护肤品。"
}
]
}
]
}
国内城市编码表下载cityid、city和ip参数
链接: https://pan.baidu.com/s/16YqQBNhNfd-Lm1cFvVY1mQ?pwd=3pnj 提取码: 3pnj
链接接:https://dev.qweather.com/
https://lbs.amap.com/api/javascript-api/guide/services/weather
免费版可用资源
需要注册
打开并注册高德开放平台,进入高德开发平台的控制台,创建应用并获取 API Key
接口示例:
https://restapi.amap.com/v3/weather/weatherInfo?key=【你的_API_KEY】8&city=110000&extensions=all
链接接:https://www.seniverse.com/
免费资源