主题
实用工具
提供访问者 IP 获取、IP 归属地查询与城市天气信息查询三个实用接口。
天气接口返回数据中的天气状况文字(如「多云」「阵雨转中雨」)已自动匹配和风天气图标 code,可直接使用 <i class="qi-{code}"></i> 渲染图标。
和风天气图标
本页及首页已引入 qweather-icons 图标字体,可直接使用:
html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/qweather-icons@1.8.0/font/qweather-icons.css">
<i class="qi-101"></i> <!-- 多云 -->
<i class="qi-307"></i> <!-- 大雨 -->
<i class="qi-901"></i> <!-- 冷 -->获取访问者 IP
无需任何参数,访问即返回当前请求者的网络 IP 地址。
- 方法:
GET - 路径:
/api/web/tools/my-ip - 参数: 无
请求示例
bash
GET /api/web/tools/my-ip响应示例
json
{
"ip": "59.42.7.147"
}字段说明
| 字段 | 说明 |
|---|---|
ip | 当前请求者的网络 IP 地址 |
IP 解析顺序
为兼容反向代理(如 Nginx / CDN),接口按以下顺序解析真实 IP:
X-Forwarded-For首段(形如client, proxy1, proxy2,取第一个非空段)X-Real-IPrequest.ip(Fastify 直连 IP)
本地开发提示
本地开发环境下访问返回的通常是 127.0.0.1 或 ::1,部署到服务器并经过反向代理后才会返回真实公网 IP。
GET在线测试
IP 归属查询
查询 IP 归属地信息(国家、省份、城市、区县、运营商、经纬度等)。
- 方法:
GET - 路径:
/api/web/tools/ip-query - 数据源: 主数据源
https://ip9.com.cn(省/市/运营商/经纬度);补充数据源https://openapi.lddgo.net(补全省/市/区县全称,合并到detail字段)
请求参数 (Query)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
ip | string | 是 | IPv4 地址,如 59.42.7.147 |
请求示例
bash
GET /api/web/tools/ip-query?ip=59.42.7.147响应示例
json
{
"ip": "59.42.7.147",
"country": "中国",
"country_code": "cn",
"prov": "广东",
"city": "广州",
"city_code": "guangzhou",
"city_short_code": "gz",
"area": "",
"post_code": "511400",
"area_code": "020",
"isp": "中国电信",
"lng": "113.38",
"lat": "22.94",
"long_ip": 992610195,
"big_area": "华南",
"detail": {
"location": "广东省 广州市 番禺区",
"province": "广东省",
"city": "广州市",
"district": "番禺区"
}
}字段说明
| 字段 | 说明 |
|---|---|
ip | 查询的 IP 地址 |
country / country_code | 国家 / 国家代码 |
prov | 省份(简称),如 广东 |
city / city_code | 城市(简称)/ 城市拼音,如 广州 / guangzhou |
area | 区县(主数据源字段,多数情况为空字符串,区县请优先使用 detail.district) |
post_code | 邮编 |
area_code | 区号 |
isp | 运营商 |
lng / lat | 经度 / 纬度 |
big_area | 大区,如 华南 |
detail | lddgo 补充的完整归属地对象;补充数据源不可用时该字段可能不存在 |
detail 对象字段:
| 字段 | 说明 |
|---|---|
location | 完整归属地(空格分隔),如 广东省 广州市 番禺区;海外 IP 可能只有国家名 |
province | 省份全称,如 广东省 |
city | 城市全称,如 广州市 |
district | 区/县全称,如 番禺区(海外或机房 IP 可能为空字符串) |
区县取值建议
主数据源 area 基本恒为空,前端展示区/县时请按 area → detail.district → 从 detail.location 末段解析 的顺序兜底。 prov/city 为简称,detail.province/detail.city 为全称,按需取用并注意去重。
GET在线测试
天气信息查询
查询城市天气信息,含今日与明日的天气状况、气温、空气质量(AQI)、16 天预报及气象预警。返回数据已自动为天气状况文字匹配和风天气图标 code。
- 方法:
GET - 路径:
/api/web/tools/weather - 数据源:
https://jk.lllt.top/api/WeatherInfo
请求参数 (Query)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
city | string | 是 | 城市名,如 乐平 |
请求示例
bash
GET /api/web/tools/weather?city=乐平响应示例(节选)
json
{
"city": "乐平",
"ip": "120.235.157.77",
"tips": "略微偏热,注意衣物变化。",
"low_temperature": 23,
"moji_city_id": 1293,
"night_condition": "多云",
"night_condition_code": 101,
"night_condition_icon": "qi-101",
"night_condition_codes": [101],
"night_condition_icons": ["qi-101"],
"quality_level": "优",
"tomorrow_aqi": 40,
"tomorrow_condition": "多云",
"tomorrow_condition_code": 101,
"tomorrow_condition_icon": "qi-101",
"tomorrow_condition_codes": [101],
"tomorrow_condition_icons": ["qi-101"],
"tomorrow_high_temperature": 33,
"tomorrow_low_temperature": 23,
"tomorrow_quality_level": "优",
"tomorrow_weather_icon_id": "1",
"update_time": "2026-09-13 23:07:52",
"today": {
"current_temp": "26℃",
"current_cond": "晴",
"current_cond_code": 100,
"current_cond_icon": "qi-100",
"night_condition": "多云",
"night_condition_code": 101,
"night_condition_icon": "qi-101",
"tomorrow_condition": "多云",
"tomorrow_condition_code": 101,
"tomorrow_condition_icon": "qi-101",
"low": "23℃",
"quality": "优",
"alert": "暂无预警信息",
"update_time": "2026-09-13 22:45:05"
},
"seven_day": [
{
"date": "2026-09-13",
"cond": "多云",
"cond_code": 101,
"cond_icon": "qi-101",
"cond_codes": [101],
"cond_icons": ["qi-101"],
"high": "34℃",
"low": "23℃"
},
{
"date": "2026-09-15",
"cond": "多云转晴",
"cond_code": 101,
"cond_icon": "qi-101",
"cond_codes": [101, 100],
"cond_icons": ["qi-101", "qi-100"],
"high": "34℃",
"low": "23℃"
}
]
}字段说明
顶层字段:
| 字段 | 类型 | 说明 |
|---|---|---|
city | string | 查询的城市名 |
ip | string | 上游接口识别到的请求方 IP |
tips | string | 生活提示(穿衣、降雨提醒等),无降雨提示时仅含温度提示 |
low_temperature | number | 今日最低温(数值,单位 ℃) |
moji_city_id | number | 墨迹天气城市 ID |
night_condition | string | 今日夜间天气状况文字 |
quality_level | string | 今日空气质量等级,如 优 |
tomorrow_condition | string | 明日天气状况文字 |
tomorrow_aqi | number | 明日空气质量指数(AQI) |
tomorrow_high_temperature | number | 明日最高温(数值,单位 ℃) |
tomorrow_low_temperature | number | 明日最低温(数值,单位 ℃) |
tomorrow_quality_level | string | 明日空气质量等级,如 优 |
tomorrow_weather_icon_id | string | 明日天气的上游图标编号(字符串) |
update_time | string | 数据更新时间,格式 YYYY-MM-DD HH:mm:ss |
today | object | 今日天气详情,见下表 |
seven_day | array | 逐日预报,固定返回 16 天(含昨日、今日及未来 14 天) |
today 对象字段:
| 字段 | 类型 | 说明 |
|---|---|---|
current_temp | string | 当前温度,如 26℃ |
current_cond | string | 当前天气状况文字 |
night_condition | string | 今日夜间天气状况文字 |
tomorrow_condition | string | 明日天气状况文字 |
low | string | 今日最低温,如 23℃ |
quality | string | 今日空气质量等级,如 优 |
alert | string | 气象预警文本;无预警时固定为 暂无预警信息 |
update_time | string | 今日天气数据更新时间 |
seven_day 数组元素字段:
| 字段 | 类型 | 说明 |
|---|---|---|
date | string | 日期,格式 YYYY-MM-DD |
cond | string | 当日天气状况文字(可能为组合天气,如 多云转晴) |
high | string | 当日最高温,如 34℃ |
low | string | 当日最低温,如 23℃ |
温度字段两种形态
- 顶层
low_temperature、tomorrow_high_temperature、tomorrow_low_temperature为 number(不带 ℃) today.current_temp、today.low与seven_day[].high/low为 string(带℃后缀)
图标字段说明
接口会为以下天气状况字段自动补充图标信息:
| 原字段 | 补充字段 | 说明 |
|---|---|---|
night_condition | night_condition_code / night_condition_icon / night_condition_codes / night_condition_icons | 夜间天气 |
tomorrow_condition | tomorrow_condition_code / tomorrow_condition_icon / tomorrow_condition_codes / tomorrow_condition_icons | 明日天气 |
today.current_cond | current_cond_code / current_cond_icon / … | 当前天气 |
today.night_condition | night_condition_code / night_condition_icon / … | 今日夜间天气 |
today.tomorrow_condition | tomorrow_condition_code / tomorrow_condition_icon / … | 明日天气 |
seven_day[].cond | cond_code / cond_icon / cond_codes / cond_icons | 每日天气 |
组合天气处理
当天气为「阵雨转中雨」这类组合天气时:
*_code/*_icon:取第一段(阵雨300),用于主图标渲染*_codes/*_icons:包含全部段[300, 306],可用于渲染过渡动画或多图标
html
<!-- 主图标 -->
<i class="qi-300"></i>
<!-- 全部段图标 -->
<i class="qi-300"></i> → <i class="qi-306"></i>天气状况与图标 code 对照表
| code | 中文 | code | 中文 | code | 中文 |
|---|---|---|---|---|---|
| 100 | 晴 | 302 | 雷阵雨 | 404 | 雨夹雪 |
| 101 | 多云 | 303 | 强雷阵雨 | 405 | 雨雪天气 |
| 102 | 少云 | 304 | 雷阵雨伴有冰雹 | 406 | 阵雨夹雪 |
| 103 | 晴间多云 | 305 | 小雨 | 407 | 阵雪 |
| 104 | 阴 | 306 | 中雨 | 408 | 小到中雪 |
| 300 | 阵雨 | 307 | 大雨 | 409 | 中到大雪 |
| 301 | 强阵雨 | 308 | 极端降雨 | 410 | 大到暴雪 |
| 309 | 毛毛雨/细雨 | 310 | 暴雨 | 499 | 雪 |
| 313 | 冻雨 | 311 | 大暴雨 | 500 | 薄雾 |
| 314 | 小到中雨 | 312 | 特大暴雨 | 501 | 雾 |
| 315 | 中到大雨 | 399 | 雨 | 502 | 霾 |
| 316 | 大到暴雨 | 400 | 小雪 | 503 | 扬沙 |
| 317 | 暴雨到大暴雨 | 401 | 中雪 | 504 | 浮尘 |
| 318 | 大暴雨到特大暴雨 | 402 | 大雪 | 507 | 沙尘暴 |
| 900 | 热 | 403 | 暴雪 | 508 | 强沙尘暴 |
| 901 | 冷 | 509 | 浓雾 | 510 | 强浓雾 |
| 999 | 未知 | 511 | 中度霾 | 512 | 重度霾 |
| 513 | 严重霾 | 514 | 大雾 | 515 | 特强浓雾 |
GET在线测试
通用说明
统一响应格式
所有接口响应均由 formatDatas 统一包装:
json
{
"code": 200,
"data": { ... },
"message": "success"
}上游接口依赖
/ip-query 与 /weather 为代理请求第三方 API,响应速度取决于上游服务。如上游异常,接口会返回 statusCode: 502 及错误信息。/my-ip 直接解析请求头,不依赖外部服务。
