OpenWeatherMap API指南

OpenWeatherMap API指南

1、注册申请“API密钥”:https://home.openweathermap.org/users/sign_up

示例API密钥:https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22

四种调用方式:

1、按城市名称

参数:

q城市名称和国家/地区代码除以逗号,使用ISO 3166国家/地区代码

API调用的示例:

api.openweathermap.org/data/2.5/weather?q=London

api.openweathermap.org/data/2.5/weather?q=London,uk

2、按城市ID

API调用的示例:

api.openweathermap.org/data/2.5/weather?id=2172797

3、按地理坐标

API调用:

api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}

4、按邮政编码

API调用的示例:

api.openweathermap.org/data/2.5/weather?zip=94040,us

多语言支持:

您可以使用lang参数以您的语言获取输出。我们支持以下语言,您可以使用相应的语言值: 
阿拉伯语 - ar,保加利亚语 - bg,加泰罗尼亚语 - ca,捷克语 - cz,德语 - de,希腊语 - el,英语 - en,波斯语(波斯语) - fa,芬兰语 - fi,法语 - fr,加利西亚语 - gl,克罗地亚语 - hr,匈牙利语 - hu,意大利语 - 日语 - 日语 - ja,韩语 - kr,拉脱维亚语 - la,立陶宛语 - LT,马其顿语 - mk,荷兰语 - nl,波兰语 - pl,Portuguese - pt,Romanian - ro,Russian - ru,Swedish - se,Slovak - sk,Slovenian - sl,Spanish - es,Turkish - tr,Ukrainian - ua,Vietnamese - vi,简体中文 - zh_cn,繁体中文 - ZH_TW。

API调用的示例:

http://api.openweathermap.org/data/2.5/forecast/daily?id=524901&lang=zh_cn

格式:

API调用的示例:

JSON api.openweathermap.org/data/2.5/weather?q=London

XML api.openweathermap.org/data/2.5/weather?q=London&mode=xml

HTML api.openweathermap.org/data/2.5/weather?q=London&mode=html

回调JavaScript代码的功能

要使用JavaScript代码,您可以将回调函数名称传递给JSONP回调。 

API调用的示例:

api.openweathermap.org/data/2.5/weather?q=London,uk&callback=test

图标地址:

URL示例: http://openweathermap.org/img/w/01d.png

或者:https://openweathermap.org/themes/openweathermap/assets/vendor/owm/img/01d.png(推荐使用)

图标集合图:

参数说明图:

查看详情访问官网:https://openweathermap.org/api

  • 7
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值