天气查询2

GET 天气 天气天气预报天气查询

查询城市天气信息,返回当前天气、24小时预报、7天预报。输入中文城市名即可查询。

GET https://api.tinyaii.cn/v1/weather2

请求参数

参数名类型必填说明示例
citystring必填城市名称,如:北京、上海、广州北京

返回字段

字段类型说明
citystring查询的城市名
current.weatherstring当前天气状况
current.tempstring当前温度(摄氏度)
current.humiditystring湿度百分比
current.pressurestring气压(百帕)
current.windstring风向风力
current.aqistring空气质量指数
current.aqi_levelstring空气质量等级
forecastarray7天预报列表
forecast[].datestring日期
forecast[].dayobject白天天气
forecast[].nightobject夜间天气
hourlyarray24小时预报列表
hourly[].timestring时间
hourly[].weatherstring天气状况
hourly[].tempstring温度

返回示例

{
  "code": 200,
  "message": "success",
  "data": {
    "city": "北京",
    "current": {
      "weather": "多云",
      "temp": "22",
      "humidity": "66",
      "pressure": "999",
      "wind": "东南风 4-5级",
      "aqi": "45",
      "aqi_level": "优"
    },
    "forecast": [
      {
        "date": "06/13",
        "day": {
          "temp": "29℃",
          "weather": "今天",
          "wind": "西南风 3-4级"
        },
        "night": {
          "temp": "20℃",
          "weather": "雷阵雨",
          "wind": "东风 1-3级"
        }
      }
    ],
    "hourly": [
      {
        "time": "23:00",
        "weather": "多云",
        "temp": "22℃"
      }
    ]
  }
}

调用示例

curl "https://api.tinyaii.cn/v1/weather2?city=北京" \
  -H "Authorization: Bearer YOUR_API_KEY"
const res = await fetch("https://api.tinyaii.cn/v1/weather2?city=北京", {
  headers: { "Authorization": "Bearer YOUR_API_KEY" },
});
console.log(await res.json());
import requests

resp = requests.get(
    "https://api.tinyaii.cn/v1/weather2",
    params={"city": "北京"},
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    timeout=10,
)
print(resp.json())

把 YOUR_API_KEY 换成你的密钥即可直接运行。密钥只保存在你自己的设备上。