使用指南

天气查询

所属分类:数据查询
接口状态:正常
调用次数:27次
收费类型: 免费(每日上限10000次)
密匙要求:

接口简介

支持查询全国所有省市(包括港澳台地区)的实时天气、空气质量指数(AQI)和天气预报。

接口信息

请求方式: GET

接口地址:

https://api.dlck.cn/api/weather.php

请求参数说明

参数名 参数类型 是否必填 参数说明
city String 城市名称,支持中文、拼音、带/不带行政区划后缀。如不提供,则自动定位
type String 查询类型:weather(实时天气,默认), aqi(空气质量), forecast(天气预报)
api_key 字符串 需要密匙的必填项,无需密匙则不必填

调用测试

请求参数:

响应结果:

等待测试...

响应示例

成功响应(200):

{ "code": 200, "msg": "success", "timestamp": 1646389200, "data": { "city": "北京市", "location": { "lat": "39.9042", "lon": "116.4074" }, "now": { "temp": "12.5", "feels_like": "11.2", "weather": "晴", "wind_dir": "东南风", "wind_scale": "2级", "humidity": "45%", "precip": "0.0mm", "pressure": "1018", "vis": "15", "cloud": "10", "update_time": "2024-12-04T10:00:00+08:00" }, "aqi": { "aqi": 56, "level": "良", "primary": "PM2.5", "pm10": 65, "pm2_5": 38, "no2": 25, "so2": 8, "co": 0.8, "o3": 45, "update_time": "2024-12-04T10:00:00+08:00", "health_advice": "空气质量可接受,对极少数敏感人群有较弱影响。" }, "forecast": [ { "date": "2024-12-04", "day_weather": "晴", "night_weather": "多云", "temp_max": "15", "temp_min": "8", "wind_dir": "东南风", "wind_scale": "2级", "humidity": "55%", "precip": "0.0", "uv_index": "4", "sunrise": "07:12", "sunset": "16:48" }, { "date": "2024-12-05", "day_weather": "多云", "night_weather": "阴", "temp_max": "14", "temp_min": "7", "wind_dir": "北风", "wind_scale": "1级", "humidity": "60%", "precip": "0.0", "uv_index": "3", "sunrise": "07:13", "sunset": "16:48" } ], "source": "qweather", "cached": false } }

使用示例

查询天气 https://yourdomain.com/api/weather.php?city=北京 查询空气质量 https://yourdomain.com/api/weather.php?city=北京&type=aqi 查询天气预报 https://yourdomain.com/api/weather.php?city=杭州&type=forecast