Open-Meteo 天气数据源
数据官方

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.

interstellar
interstellar
浏览645
使用48

Skill 文件

SKILL.md
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].latituderesults[0].longituderesults[0].nameresults[0].countryresults[0].timezone

results 为空,说明地名无法识别,应告知用户换更精确的地名。

2. 实时天气

GET https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}&current=temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m&timezone=auto

关键返回字段:current.timecurrent.temperature_2mcurrent.relative_humidity_2mcurrent.weather_codecurrent.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 雷暴。回答时把代码翻译成中文天气描述。

调用示例

查「杭州今天的天气」:

  1. 先地理编码拿经纬度:
curl(url = "https://geocoding-api.open-meteo.com/v1/search?name=杭州&count=1&language=zh")

得到 latitude=30.29365longitude=120.16142

  1. 再查实时天气:
curl(url = "https://api.open-meteo.com/v1/forecast?latitude=30.29365&longitude=120.16142&current=temperature_2m,weather_code,wind_speed_10m&timezone=auto")

读取 current.temperature_2m 等字段,把 weather_code 翻成中文后回答用户。

错误处理

  • 400:参数有误(如经纬度缺失、变量名拼错),核对 query 参数。
  • geocoding results 为空:地名无法识别,请用户提供更精确的地名。
  • 其他非 2xx:把 status 与响应体摘要反馈给用户。
Ln 1, Col 1MarkdownSpaces: 2
No errors