cURL
curl "https://api.ruseo.cn/api/weather_ip?ip=49.234.56.79&day=3&hourtype=1&suntimetype=1"
国内天气预报查询,支持 1-7 天预报。通过 IP 自动定位城市,返回当日天气、未来预报、预警信息、时段预报、日出日落时间等。数据来源于中国气象局。
https://api.ruseo.cn/api/weather_ip
接口调用前需要确认的核心配置。
/api/weather_ipweather_ip必填参数必须传入,示例值可直接用于联调。
免费API不强制要求API Key,但如果您希望统计个人调用次数,请在请求时附加参数 key=您的API_KEY。
注册账号后即可获得API Key。
| 参数名 | 必填 | 类型 | 说明 | 示例值 |
|---|---|---|---|---|
key |
否 | string | 可选参数:携带此参数可统计您的个人调用次数。请注册账号获取API Key。 | YOUR_API_KEY |
ip |
否 | string | IP 地址,不传则自动获取当前请求 IP | 49.234.56.79 |
day |
否 | integer | 查询天数 1-7,默认 1 | 3 |
hourtype |
否 | integer | 时段预报 0=不返回 1=返回,默认 0 | 1 |
suntimetype |
否 | integer | 日出日落时间 0=不返回 1=返回,默认 0 | 1 |
优先使用示例地址测试请求参数是否正确。
https://api.ruseo.cn/api/weather_ip?ip=49.234.56.79&day=3&hourtype=1&suntimetype=1
curl "https://api.ruseo.cn/api/weather_ip?ip=49.234.56.79&day=3&hourtype=1&suntimetype=1"
$url = 'https://api.ruseo.cn/api/weather_ip?ip=49.234.56.79&day=3&hourtype=1&suntimetype=1';
$response = file_get_contents($url);
$data = json_decode($response, true);
fetch('https://api.ruseo.cn/api/weather_ip?ip=49.234.56.79&day=3&hourtype=1&suntimetype=1')
.then(res => res.json())
.then(data => console.log(data));
实际返回内容以接口脚本处理结果为准。
{
"code": 0,
"msg": "success",
"data": {
"route": "weather_ip",
"example": true
}
}
| 参数名 | 类型 | 说明 | 示例值 |
|---|---|---|---|
code |
integer | 业务状态码,0 表示成功 | 0 |
msg |
string | 接口调用结果说明 | success |
data |
object | 接口返回的业务数据 | {} |
data.query.ip |
string | 查询的 IP 地址 | 49.234.56.79 |
data.query.day |
integer | 查询天数 | 3 |
data.location.country |
string | 国家 | 中国 |
data.location.province |
string | 省份 | 云南 |
data.location.city |
string | 城市 | 砚山 |
data.current.temperature |
number | 当前温度 | 28.2 |
data.current.humidity |
integer | 当前湿度 | 23 |
data.forecast |
array | 天气预报数组 | [] |
data.forecast[].date |
string | 日期 | 2026-05-29 |
data.forecast[].dayWeather |
string | 白天天气 | 多云 |
data.forecast[].dayTemp |
string | 白天温度 | 27 |
data.forecast[].nightTemp |
string | 夜间温度 | 14 |
点击左侧“发送请求”查看结果...