天气查询

GETPOST 天气 热门

查询城市当前天气及7天预报,数据源tianqi.com

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

请求参数

参数名类型必填说明示例
citystring必填城市名称(中文或拼音),如:北京、上海、guangzhou北京

返回字段

字段类型说明
data.citystring城市名称
data.current.tempstring当前温度(℃)
data.current.weatherstring天气状况
data.current.temp_lowstring最低温度
data.current.temp_highstring最高温度
data.current.humiditystring湿度(%)
data.current.windstring风向
data.current.wind_levelstring风力等级
data.current.aqistring空气质量
data.current.pm25stringPM2.5
data.current.uvstring紫外线强度
data.current.sunrisestring日出时间
data.current.sunsetstring日落时间
data.forecastarray7天天气预报
data.forecast[].datestring日期
data.forecast[].weekstring星期
data.forecast[].weatherstring天气状况
data.forecast[].temp_lowstring最低温度
data.forecast[].temp_highstring最高温度
data.forecast[].windstring风向
data.forecast[].wind_levelstring风力等级

返回示例

{
  "code": 200,
  "data": {
    "city": "北京",
    "current": {
      "temp": "23",
      "weather": "多云",
      "temp_low": "22",
      "temp_high": "29",
      "humidity": "65",
      "wind": "东北风",
      "wind_level": "1级",
      "aqi": "优",
      "pm25": "11",
      "uv": "很弱",
      "sunrise": "04:48",
      "sunset": "19:47"
    },
    "forecast": [
      {
        "date": "06月30日",
        "week": "星期二",
        "weather": "多云转小雨",
        "temp_low": "21",
        "temp_high": "28",
        "wind": "东北风",
        "wind_level": "1级"
      },
      {
        "date": "07月01日",
        "week": "星期三",
        "weather": "多云转小雨",
        "temp_low": "22",
        "temp_high": "28",
        "wind": "东风",
        "wind_level": "1级"
      }
    ]
  },
  "message": "success"
}

调用示例

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

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

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