SuperAPI AI 工具集

openweather

编程与开发

查看项目

更新于 10-16 02:36

技能介绍

用途:当用户提到 OpenWeather、weather、forecast、temperature 或需要天气、预报、历史气候数据时,通过 OpenWeather API 获取数据。

主要能力:按城市名或经纬度查询实时天气;获取 5 天 / 3 小时预报;使用 One Call API 3.0 获取当前、分钟、小时、每日数据;使用地理编码接口解析城市名称。

使用方式:API 通过 appid 查询参数传入密钥,基础地址为 https://api.openweathermap.org。常用命令示例: 实时天气(城市):curl -s -G "https://api.openweathermap.org/data/2.5/weather" --data-urlencode "q=Beijing" --data-urlencode "units=metric" --data-urlencode "appid=$OPENWEATHER_TOKEN" 实时天气(坐标):curl -s -G "https://api.openweathermap.org/data/2.5/weather" --data-urlencode "lat=39.9042" --data-urlencode "lon=116.4074" --data-urlencode "units=metric" --data-urlencode "appid=$OPENWEATHER_TOKEN" 5 天 / 3 小时预报:curl -s -G "https://api.openweathermap.org/data/2.5/forecast" --data-urlencode "q=Palo Alto,US" --data-urlencode "units=imperial" --data-urlencode "appid=$OPENWEATHER_TOKEN" One Call 3.0:curl -s -G "https://api.openweathermap.org/data/3.0/onecall" --data-urlencode "lat=37.4220" --data-urlencode "lon=-122.0841" --data-urlencode "units=metric" --data-urlencode "exclude=minutely,alerts" --data-urlencode "appid=$OPENWEATHER_TOKEN" 地理编码:curl -s -G "https://api.openweathermap.org/geo/1.0/direct" --data-urlencode "q=Tokyo" --data-urlencode "limit=5" --data-urlencode "appid=$OPENWEATHER_TOKEN"

连接排查:请求失败时运行 zero doctor check-connector --env-name OPENWEATHER_TOKEN 或 zero doctor check-connector --url https://api.openweathermap.org/data/2.5/weather --method GET。

限制与准则:需显式指定单位,否则默认开尔文,建议用 metric 或 imperial;One Call 3.0 需要付费计划,免费层使用 data/2.5/weather 与 data/2.5/forecast 即可;配额按调用次数计算,应尽量缓存,实时天气每小时仅变化数次;城市名解析统一走 geo/1.0/direct,不要自行解析自由文本。历史气候数据的具体接口与用法资料暂未提供。