SuperAPI AI 工具集

weather-query

通用与其它

查看项目

更新于 10-15 15:09

技能介绍

Weather Query Skill 是一个让 AI 智能体获取中国各地实时天气和天气预报的技能,数据来自 60s API。

【用途】 当用户询问天气状况、天气预报或某地气候信息时使用。具体包括:查询当前天气状况、获取天气预报、需要温度/湿度/风力信息、请求空气质量数据、为户外活动规划而查询天气等场景。

【主要能力】

  1. 实时天气:接口 URL 为 https://60s.viki.moe/v2/weather/realtime,方法 GET。
  2. 天气预报:接口 URL 为 https://60s.viki.moe/v2/weather/forecast,方法 GET。 参数 query(必填)为中文地点名,可以是城市名(如“北京”“上海”“广州”),也可以是区名(如“海淀区”“浦东新区”)。 实时天气返回字段包括 location、weather、temperature、humidity、wind、air_quality、updated。预报返回 location 与 forecast 数组,每个元素含 date、day_of_week、weather、temp_low、temp_high、wind。

【使用方式】 Python 调用示例: import requests

def get_realtime_weather(query): url = 'https://60s.viki.moe/v2/weather/realtime' response = requests.get(url, params={'query': query}) return response.json()

weather = get_realtime_weather('北京') print(f"☁️ {weather['location']}天气") print(f"🌡️ 温度:{weather['temperature']}°C") print(f"💨 风速:{weather['wind']}") print(f"💧 湿度:{weather['humidity']}")

预报调用示例: def get_weather_forecast(query): url = 'https://60s.viki.moe/v2/weather/forecast' response = requests.get(url, params={'query': query}) return response.json()

forecast = get_weather_forecast('上海') for day in forecast['forecast']: print(f"{day['date']}: {day['weather']} {day['temp_low']}°C ~ {day['temp_high']}°C")

bash 示例: curl "https://60s.viki.moe/v2/weather/realtime?query=北京" curl "https://60s.viki.moe/v2/weather/forecast?query=上海"

【适用场景】

  1. 基于天气给出建议:如温度高于 30 度提示防暑多喝水,低于 5 度提示保暖,出现“雨”提示带伞,空气质量为“差”或“重度污染”时建议戴口罩。
  2. 多城市天气对比:批量查询后找最热与最冷城市。
  3. 出行天气检查:从预报中筛出无雨无雪的日期作为适合出行日期。

【限制与注意事项】 地点名必须使用中文字符;使用前应检查地点是否有效;天气数据会定期更新但可在短期内缓存;若某区名查询失败,可改用城市名(例如“北京”代替“朝阳区”),并尽量使用标准城市名;若数据看似过期,可检查响应中的 updated 时间戳。该 API 支持中国大多数城市和区,包括省会城市、主要城市与部分区。以上为资料中明确提供的功能与用法,未提及的收费、价格、平台等信息暂未提供。