API详情
高德天气API
高德开放平台
免费
官方
实时数据
4.8
评分
1.2M
调用量
99.9%
可用率
50ms
响应时间
接口描述
高德天气API提供全球城市天气预报、实时天气、历史天气数据查询服务。支持多种数据格式输出,包括JSON、XML等。 提供详细的天气信息,包括温度、湿度、风速、降水量、空气质量等多维度数据。
计费说明
• 免费额度:每日1000次调用
• 超出后:0.01元/次
• 企业版:联系客服获取优惠价格
请求参数
city
必填
string
城市名称或城市编码,支持中文、英文、拼音
key
必填
string
用户的API Key,在开发者中心获取
extensions
可选
string
返回数据类型:base(基础) 或 all(详细),默认base
代码示例
JavaScript
fetch('https://restapi.amap.com/v3/weather/weatherInfo?city=北京&key=YOUR_KEY') .then(response => response.json()) .then(data => { console.log(data); }) .catch(error => { console.error('Error:', error); });
Python
import requests url = "https://restapi.amap.com/v3/weather/weatherInfo" params = { "city": "北京", "key": "YOUR_KEY" } response = requests.get(url, params=params) data = response.json() print(data)
返回示例
JSON
{ "status": "1", "count": "1", "info": "OK", "infocode": "10000", "lives": [ { "province": "北京", "city": "北京市", "adcode": "110000", "weather": "晴", "temperature": "25", "winddirection": "南", "windpower": "≤3", "humidity": "45", "reporttime": "2024-01-15 16:00:00" } ] }
在线测试 收藏