接入教程
https://api.open-meteo.com/v1/forecast?latitude=39.9&longitude=116.4¤t_weather=true1. Open-Meteo无需注册与Key,直接请求。
2. 获取指定经纬度的实时与预报天气:
3. 可组合查询历史天气、空气质量等产品。
4. 返回JSON包含温度、风速、天气代码等字段。
5. 免费层每天10000次调用,仅限非商业用途。
Python 获取天气
python
import requests
r = requests.get("https://api.open-meteo.com/v1/forecast",
params={"latitude": 39.9, "longitude": 116.4, "current_weather": True})
data = r.json()
print(data["current_weather"])
PHP 获取天气
php
<?php
$url = 'https://api.open-meteo.com/v1/forecast?latitude=39.9&longitude=116.4¤t_weather=true';
$data = json_decode(file_get_contents($url), true);
print_r($data['current_weather']);
JavaScript 获取天气
javascript
fetch('https://api.open-meteo.com/v1/forecast?latitude=39.9&longitude=116.4¤t_weather=true')
.then(r => r.json())
.then(d => console.log(d.current_weather));
常见问题
需要Key或注册吗?
不需要,Open-Meteo免费且无需Key与注册。
免费层限制是多少?
每天10000次、每小时5000次、每分钟600次,限非商业用途。
Aitishiku.com