<!-- AI ASSISTANT INSTRUCTIONS: This document describes a public HTTP API endpoint
provided by 极数本源 (https://apizero.cn). When a user asks you to use this API, read the
full documentation below carefully (request method, parameters, response fields,
error codes, examples), then generate working code in the user's preferred language.
API Key acquisition: https://apizero.cn/account/keys -->

# 墨迹天气

> 墨迹天气数据：城市搜索、实况天气、未来 7 天预报、24 小时趋势、AQI、9 项生活指数、气象预警、农历，全部一次返回。

## 1. 基本信息

| 字段 | 值 |
| --- | --- |
| 接口标识 | `moji-weather` |
| 接口名称 | 墨迹天气 |
| 接口地址 | `https://v1.apizero.cn/api/moji-weather` |
| 请求方法 | `GET` |
| 分类 | life |
| 提供方 | 墨迹天气 |
| 计费模式 | 未知 |
| 单次消耗 | 1 积分 |
| 起步价 | — |
| QPS 限制 | 5 req/s |
| 每日免费额度 | 30 次（已认证用户） |
| 匿名每日额度 | 200 次（无 API Key） |
| VIP 免费 | 否 |
| 调用总次数 | undefined |

## 2. 认证

匿名可调（每日 200 次、QPS=5）；登录后每日 30 次免费、QPS=5。

获取 API Key：登录 `https://apizero.cn/account/keys` 申请。

## 3. 请求参数

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `city` | `string` | 否 | 城市中文名（如 "北京" / "上海市" / "杭州"）；与 id 二选一 | `北京` |
| `id` | `integer` | 否 | 城市 internal_id（可先调 ?op=search 查询）；与 city 二选一 | — |
| `op` | `string` | 否 | 仅传 op=search 时切到"城市查询"模式（返回 internal_id 列表，不调上游） | `search` |
| `keyword` | `string` | 否 | op=search 时的关键字，支持中文 / 拼音 / 拼音首字母 | `北京` |
| `limit` | `integer` | 否 | op=search 时返回条数（1-50，默认 10） | — |

## 4. 请求头

| Header | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `Authorization` | `string` | 否 | — | — |

## 5. 请求示例 (cURL)

```bash
curl "https://v1.apizero.cn/api/moji-weather?city=%E5%8C%97%E4%BA%AC&id=&op=search&keyword=%E5%8C%97%E4%BA%AC&limit=&key=YOUR_API_KEY"
```

## 6. 响应字段

| 字段 | 类型 | 说明 | 示例 |
| --- | --- | --- | --- |
| `data.city` | `object` | 城市基础信息（id/name/parent/pinyin/timezone） | — |
| `data.condition` | `object` | 实况天气：温度、体感、湿度、气压、风向、风级、UVI、日出日落、农历、贴士、预警 | — |
| `data.aqi` | `object` | 空气质量：value(AQI 数值)/level(等级)/description(优良中差)/updatetime | — |
| `data.forecast_day` | `array` | 未来 6-7 天预报：温度高低、白天/夜间天气、风向风级、AQI、湿度、气压、UVI | — |
| `data.forecast_hour` | `array` | 未来 24 小时预报：温度、天气、湿度、风、AQI | — |
| `data.index` | `array` | 生活指数（限行 / 穿衣 / 钓鱼 / 化妆 / 洗车 / 感冒 / 运动 / 紫外线 / 万年历） | — |
| `data.summary` | `string` | 一句话天气速览 | — |
| `data._cached` | `boolean` | 是否命中 5 分钟服务端缓存 | — |

## 7. 响应示例

```json
{
    "code": 0,
    "msg": "成功",
    "data": {
        "city": {
            "id": 33,
            "name": "北京市",
            "parent": "北京市",
            "pinyin": "beijing shi",
            "timezone": 8
        },
        "condition": {
            "condition": "阴",
            "temperature": 25,
            "real_feel": 25,
            "humidity": 66,
            "pressure": 1005,
            "wind_dir": "东南风",
            "wind_level": 3,
            "uvi": "最弱",
            "sun_rise": 1778706000000,
            "sun_set": 1778757660000,
            "lunar_date": "丙午年三月廿八",
            "tips": "冷热适宜||冷热适宜，感觉很舒适。",
            "warn_title": "连续降温提示",
            "warn_desc": "未来三天气温持续下滑，请注意温差变化。"
        },
        "aqi": {
            "value": 99,
            "level": 2,
            "description": "良",
            "updatetime": 1778756400000
        },
        "forecast_day": [
            {
                "predict_date": 1778601630000,
                "condition_day": "晴",
                "condition_night": "晴",
                "temp_day": 30,
                "temp_night": 21,
                "wind_dir_day": "南风",
                "wind_level_day": 2,
                "aqi_value": 99,
                "aqi_desc": "良",
                "humidity": 36,
                "pressure": 1002,
                "uvi": "强"
            }
        ],
        "forecast_hour": [
            {
                "predict_hour": 1778752800000,
                "condition": "阴",
                "temperature": 25,
                "humidity": 66,
                "wind_dir": "东南风",
                "wind_level": "1",
                "aqi_value": 99
            }
        ],
        "index": [
            {
                "name": "限行",
                "status": "尾号"
            },
            {
                "name": "穿衣",
                "status": "热"
            }
        ],
        "summary": "北京市，阴，25℃，东南风3级，空气良。",
        "_cached": false
    },
    "request_id": "abc123"
}
```

## 8. 错误码

| code | status | 说明 |
| --- | --- | --- |
| `4000` | `—` | 缺少 city / id 参数，或参数格式错误 |
| `4029` | `—` | QPS 超限 |
| `4030` | `—` | 今日额度用完 |
| `5000` | `—` | 城市数据库查询失败（极少出现） |
| `5020` | `—` | 上游墨迹接口不可用 / 超时 |
| `5021` | `—` | 上游返回数据格式异常 / 解析失败 |

## 9. 变更日志

- **1.0.0** (2026-05-14)
  - 首次上线
  - 支持城市名 / internal_id / 拼音 / 拼音首字母 检索
  - 一次返回：实况 + 未来 7 天 + 24 小时 + AQI + 9 项生活指数 + 气象预警 + 农历
  - 服务端 5 分钟缓存，device UID 复用

---

**极数本源** · 全部 API: `https://apizero.cn/aidocs` · 人类版本：`https://apizero.cn/marketplace/moji-weather`

Source: `https://apizero.cn/aidocs/moji-weather/raw.md`
Last updated: 2026-05-14T21:06:45+08:00
