cURL
curl "https://api.ruseo.cn/api/weather?sheng=%E5%9B%9B%E5%B7%9D&place=%E7%BB%B5%E9%98%B3&day=3&hourtype=1&suntimetype=1"
提供全国各省市县天气预报查询,支持 1-7 天预报、时段天气、日出日落时间、天气预警等。数据来源于中国气象局。
https://api.ruseo.cn/api/weather
接口调用前需要确认的核心配置。
/api/weatherweather必填参数必须传入,示例值可直接用于联调。
免费API不强制要求API Key,但如果您希望统计个人调用次数,请在请求时附加参数 key=您的API_KEY。
注册账号后即可获得API Key。
| 参数名 | 必填 | 类型 | 说明 | 示例值 |
|---|---|---|---|---|
key |
否 | string | 可选参数:携带此参数可统计您的个人调用次数。请注册账号获取API Key。 | YOUR_API_KEY |
sheng |
否 | string | 省份名称(一级行政区,直辖市也为一级行政区)。如:四川、北京市、四川省。 | 四川 |
place |
是 | string | 要查询的地点,一般为市级名称或该市下的某地点名称。如:绵阳、上海、广州、深圳、大兴区。 | 绵阳 |
day |
否 | integer | 查询天数,可传 1 到 7,代表 1 到 7 天内天气预报。默认为 1。 | 3 |
hourtype |
否 | integer | 是否返回时段天气预报。0=不返回,1=返回。默认为 0。 | 1 |
suntimetype |
否 | integer | 是否返回 7 天日出日落详细时间。0=不返回,1=返回。默认为 0。 | 1 |
优先使用示例地址测试请求参数是否正确。
https://api.ruseo.cn/api/weather?sheng=%E5%9B%9B%E5%B7%9D&place=%E7%BB%B5%E9%98%B3&day=3&hourtype=1&suntimetype=1
curl "https://api.ruseo.cn/api/weather?sheng=%E5%9B%9B%E5%B7%9D&place=%E7%BB%B5%E9%98%B3&day=3&hourtype=1&suntimetype=1"
$url = 'https://api.ruseo.cn/api/weather?sheng=%E5%9B%9B%E5%B7%9D&place=%E7%BB%B5%E9%98%B3&day=3&hourtype=1&suntimetype=1';
$response = file_get_contents($url);
$data = json_decode($response, true);
fetch('https://api.ruseo.cn/api/weather?sheng=%E5%9B%9B%E5%B7%9D&place=%E7%BB%B5%E9%98%B3&day=3&hourtype=1&suntimetype=1')
.then(res => res.json())
.then(data => console.log(data));
实际返回内容以接口脚本处理结果为准。
{
"code": 0,
"msg": "success",
"data": {
"route": "weather",
"example": true
}
}
| 参数名 | 类型 | 说明 | 示例值 |
|---|---|---|---|
result.country |
string | 查询地址国家。 | 中国 |
result.province |
string | 查询地址省级。 | 云南 |
result.city |
string | 查询地址市级或地区。 | 砚山 |
result.location |
string | 天气预报地址。 | 砚山 |
result.longitude |
string | 地区经度。 | 104.340 |
result.latitude |
string | 地区纬度。 | 23.600 |
result.today.day_weather |
string | 当日白天天气。 | 多云 |
result.today.day_temp |
string | 当日白天温度(℃)。 | 27 |
result.today.day_wind |
string | 当日白天风向。 | 西南风 |
result.today.day_wind_level |
string | 当日白天风力等级。 | 3~4 级 |
result.today.night_weather |
string | 当日夜间天气。 | 多云 |
result.today.night_temp |
string | 当日夜间温度(℃)。 | 14 |
result.current.temperature |
number | 当前温度(℃)。 | 28.2 |
result.current.feels_like |
number | 体感温度(℃)。 | 26.3 |
result.current.humidity |
number | 当前湿度(%)。 | 23 |
result.current.pressure |
number | 当前气压(hPa)。 | 837 |
result.current.wind_direction |
string | 当前风向。 | 西南风 |
result.current.wind_scale |
string | 当前风级。 | 3 级 |
result.alerts[].title |
string | 预警标题。 | 砚山县气象台发布大风蓝色预警 |
result.alerts[].type |
string | 预警天气类别。 | 大风 |
result.alerts[].level |
string | 预警等级。 | 蓝色 |
result.alerts[].effective |
string | 预警生效时间。 | 2026/03/30 12:37 |
result.forecast_2.day_weather |
string | 第 2 天白天天气。 | 晴 |
result.forecast_2.day_temp |
string | 第 2 天白天温度。 | 28 |
result.forecast_2.night_weather |
string | 第 2 天夜间天气。 | 多云 |
result.forecast_2.night_temp |
string | 第 2 天夜间温度。 | 15 |
result.forecast_3.day_weather |
string | 第 3 天白天天气。 | 多云 |
result.forecast_3.day_temp |
string | 第 3 天白天温度。 | 29 |
result.forecast_3.night_weather |
string | 第 3 天夜间天气。 | 阴 |
result.forecast_3.night_temp |
string | 第 3 天夜间温度。 | 16 |
result.hourly_1[].时间 |
string | 时段天气预报 - 时间点。 | 17:00 |
result.hourly_1[].天气 |
string | 时段天气预报 - 天气状况。 | 多云 |
result.hourly_1[].气温 |
string | 时段天气预报 - 气温。 | 26.9℃ |
result.hourly_1[].风速 |
string | 时段天气预报 - 风速。 | 6.7m/s |
result.sunrise_sunset[].date |
string | 日出日落时间表 - 日期。 | 2026-03-30 |
result.sunrise_sunset[].sunrise |
string | 日出日落时间表 - 日出时间。 | 06:56:51 |
result.sunrise_sunset[].sunset |
string | 日出日落时间表 - 日落时间。 | 19:17:30 |
result.sunrise_sunset[].day_length |
string | 日出日落时间表 - 昼长。 | 12:20:39 |
code |
integer | 状态码:200=成功,400=错误。 | 200 |
msg |
string | 返回消息。成功时为 success,错误时显示错误提示。 | success |
data.update_time |
string | 数据更新时间。 | 2026-05-29 17:27:00 |
点击左侧“发送请求”查看结果...