
Open-Meteo 天气数据源
Use when the user asks for weather data of a location — current conditions, hourly or daily forecast, temperature, precipitation, wind (keywords:天气、气温、温度、降水、下雨、风力、预报、weather、forecast). Provides free no-auth access to the Open-Meteo weather and geocoding API. Do NOT use for non-weather data.
Skill 文件
| name | open-meteo-datasource |
|---|---|
| title | Open-Meteo 天气数据源 |
| description | Use when the user asks for weather data of a location — current conditions, hourly or daily forecast, temperature, precipitation, wind (keywords:天气、气温、温度、降水、下雨、风力、预报、weather、forecast). Provides free no-auth access to the Open-Meteo weather and geocoding API. Do NOT use for non-weather data. |
| tools | curl |
Open-Meteo 天气数据源
通过 curl tool 调用 Open-Meteo API 获取天气预报与实时天气数据。
鉴权
Open-Meteo 免费且无需鉴权,直接发请求即可,不要传任何 token 或 API key。
通用约定
- 天气接口 Base URL:
https://api.open-meteo.com - 地理编码 Base URL:
https://geocoding-api.open-meteo.com - 所有接口都是
GET,参数通过 query string 传递,返回 JSON。 - 天气接口只接受经纬度(
latitude/longitude),不接受城市名。当用户给的是地名时,必须先用「地理编码」接口把地名转成经纬度,再查天气。 - 时区建议带上
timezone=auto,让返回时间对齐当地时区。
常用接口
1. 地理编码:地名 → 经纬度
GET https://geocoding-api.open-meteo.com/v1/search?name={地名}&count=1&language=zh关键返回字段:results[0].latitude、results[0].longitude、results[0].name、results[0].country、results[0].timezone。
若
results为空,说明地名无法识别,应告知用户换更精确的地名。
2. 实时天气
GET https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}¤t=temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m&timezone=auto关键返回字段:current.time、current.temperature_2m、current.relative_humidity_2m、current.weather_code、current.wind_speed_10m;单位在 current_units 中。
3. 逐日预报(默认 7 天,最多 16 天)
GET https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}&daily=temperature_2m_max,temperature_2m_min,precipitation_sum,weather_code&forecast_days=7&timezone=auto关键返回字段:daily.time[](日期数组)、daily.temperature_2m_max[]、daily.temperature_2m_min[]、daily.precipitation_sum[]、daily.weather_code[];这些数组按 daily.time 下标一一对应。
4. 逐小时预报
GET https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}&hourly=temperature_2m,precipitation,wind_speed_10m&forecast_days=2&timezone=auto关键返回字段:hourly.time[]、hourly.temperature_2m[]、hourly.precipitation[]、hourly.wind_speed_10m[],按下标对应。
weather_code 释义
weather_code 为 WMO 天气代码,常用映射:0 晴;1-3 多云转晴/多云;45/48 雾;51-67 毛毛雨/雨;71-77 雪;80-82 阵雨;95-99 雷暴。回答时把代码翻译成中文天气描述。
调用示例
查「杭州今天的天气」:
- 先地理编码拿经纬度:
curl(url = "https://geocoding-api.open-meteo.com/v1/search?name=杭州&count=1&language=zh")得到 latitude=30.29365、longitude=120.16142。
- 再查实时天气:
curl(url = "https://api.open-meteo.com/v1/forecast?latitude=30.29365&longitude=120.16142¤t=temperature_2m,weather_code,wind_speed_10m&timezone=auto")读取 current.temperature_2m 等字段,把 weather_code 翻成中文后回答用户。
错误处理
400:参数有误(如经纬度缺失、变量名拼错),核对 query 参数。- geocoding
results为空:地名无法识别,请用户提供更精确的地名。 - 其他非 2xx:把
status与响应体摘要反馈给用户。