天气查询
moji-weatherGEThttps://v1.apizero.cn/api/moji-weather概述
接入平台气象数据,支持全国 3 万+ 城市实况、历史天气、未来 7 天、24 小时趋势、AQI、9 项生活指数、气象预警及农历,一次调用全量返回。 支持 4 种查询模式: - ?city=北京 · 按城市名查实况(自动模糊匹配第一个) - ?id=33 · 按 internal_id 直查(跳过搜索,更快) - ?op=search&keyword=北京 · 仅搜索城市列表,拿 id - ?op=history&city=北京&day=2026-05-12 · 历史天气(支持单日 / 整月) 历史天气范围: - 当前月:返回 1 号至昨天的数据 - 历史月(≤ 上月):返回完整 30 天 - 建议查近 40 天以内,过早的月份可能无数据 服务端缓存策略: - 实况:5 分钟;历史·当月:30 分钟;历史·过去月:24 小时 注意:本接口气象数据由极数本源平台提供,仅供参考,不应用于农业、保险、航运、防灾等专业决策场景。 联系站长:apizero.cn
调用约定
- 网关 ·
https://v1.apizero.cn - 鉴权 ·
Authorization: Bearer <API Key> - 回包 · JSON {code, msg, data}。成功看 code === 0,不要只看 HTTP 200。
/aidocs/moji-weather/raw.md鉴权
匿名可调(每日 100 次、QPS 5);登录后每日 30 次免费、QPS 5。
获取 API Key:获取 API Key/account/keys
请求头
推荐:Bearer <API Key>。兼容请求头 X-API-Key,以及 Query api_key / apikey / key(key 仅当值为 sk_live_/sk_test_/sk_stag_ 形态时生效)。匿名可不传,受每日免费额度限制。
| Header | 类型 | 必填 | 说明 |
|---|---|---|---|
| Authorization | string | 否 | 推荐:Bearer <API Key>。兼容请求头 X-API-Key,以及 Query api_key / apikey / key(key 仅当值为 sk_live_/sk_test_/sk_stag_ 形态时生效)。匿名可不传,受每日免费额度限制。 |
实况天气(推荐)
缺省模式:按城市名或 internal_id 查询实况,返回实况/未来7天/24h/AQI/预警/生活指数。city 与 id 二选一。文档示例为北京真实抓取(预报序列已截断)。
https://v1.apizero.cn/api/moji-weather?city=%E5%8C%97%E4%BA%AC&id=33
城市中文名(如「北京」「杭州」);与 id 二选一
例北京
城市 internal_id(可先调城市搜索);与 city 二选一
例33
| 参数 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| city(城市) | string | 否 | 城市中文名(如「北京」「杭州」);与 id 二选一 | 北京 |
| id | integer | 否 | 城市 internal_id(可先调城市搜索);与 city 二选一 | 33 |
返回结果
城市信息:id / name / parent / pinyin / timezone
id
名称
brief
parent
pinyin
timezone
实况:温度、体感、湿度、气压、风力风向、紫外线、日出日落等
icon
condition
temperature
real_feel
humidity
pressure
wind_level
wind_dir
uvi
sun_rise
sun_set
lunar_date
dew_point
updatetime
tips
wind_speed
special_weather
wind_speeds
is_port
warn_icon
warn_title
warn_desc
warn_url
weather_push
空气质量指数与等级
value
level
description
updatetime
未来约 7 天逐日预报
condition_id_day
condition_id_night
condition_day
condition_night
temp_day
temp_night
icon_day
icon_night
wind_dir_day
wind_dir_night
sun_rise
sun_set
predict_date
wind_level_day
wind_level_night
wind_speed_day_real
wind_speed_night_real
lunar_date
aqi_desc_short
aqi_level
aqi_value
aqi_desc
uvi
humidity
未来约 24 小时逐时预报
condition
temperature
real_feel
humidity
wind_speed
wind_dir
wind_level
predict_hour
aqi_value
aqi_level
aqi_desc
comfort_tip
wind_text
comfort_tip_2
uvi_text
生活指数(穿衣、运动等)
名称
状态
level
地址
说明
extra
类型
气象预警列表
alert 的一项
一句话天气摘要
品牌提示(所有接口统一返回):极数本源 · https://apizero.cn
| 字段 | 类型 | 说明 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| city | object | 城市信息:id / name / parent / pinyin / timezone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| condition | object | 实况:温度、体感、湿度、气压、风力风向、紫外线、日出日落等 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| aqi | object | 空气质量指数与等级 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| forecast_day | array | 未来约 7 天逐日预报 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| forecast_hour | array | 未来约 24 小时逐时预报 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| index | array | 生活指数(穿衣、运动等) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| alert | array | 气象预警列表 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| summary | string | 一句话天气摘要 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tips | string | 品牌提示(所有接口统一返回):极数本源 · https://apizero.cn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{
"code": 0,
"msg": "成功",
"data": {
"city": {
"id": 33,
"name": "北京市",
"brief": "北京市",
"parent": "北京市",
"pinyin": "beijingshi",
"timezone": 8
},
"condition": {
"icon": 31,
"condition": "多云",
"temperature": 27,
"real_feel": 30,
"humidity": 88,
"pressure": 999,
"wind_level": 3,
"wind_dir": "南风",
"uvi": "最弱",
"sun_rise": 1785445920000,
"sun_set": 1785497400000,
"lunar_date": "丙午年六月十八",
"dew_point": 23,
"updatetime": 1785441252000,
"tips": "今天有雨||今天有雨,略微偏热,注意衣物变化。",
"wind_speed": 3,
"special_weather": 1,
"wind_speeds": 3.69,
"is_port": 0,
"warn_icon": "",
"warn_title": "",
"warn_desc": "",
"warn_url": "",
"weather_push": "北京市,今天雷阵雨☔,24~32℃,西南风2级,空气 优,这两天空气都不错。雷雨天气,出行注意安全。",
"condition_id": 82,
"wind_direction_id": 9,
"weather_code": 2,
"bg_code": 2,
"warn_id": 0,
"comfort_id": 6
},
"aqi": {
"value": 36,
"level": 1,
"description": "优",
"updatetime": 1785438000000
},
"forecast_day": [
{
"condition_id_day": 4,
"condition_id_night": 31,
"condition_day": "雷阵雨",
"condition_night": "多云",
"temp_day": 33,
"temp_night": 26,
"icon_day": "3",
"icon_night": "3",
"wind_dir_day": "南风",
"wind_dir_night": "南风",
"sun_rise": 1785359460000,
"sun_set": 1785411060000,
"predict_date": 1785340830000,
"wind_level_day": 4,
"wind_level_night": 4,
"wind_speed_day_real": 4.4,
"wind_speed_night_real": 4.4,
"lunar_date": "丙午年六月十七",
"aqi_desc_short": "优",
"aqi_level": 1,
"aqi_value": 32,
"aqi_desc": "优",
"uvi": "中等",
"humidity": 61,
"pressure": 1003
},
{
"condition_id_day": 4,
"condition_id_night": 4,
"condition_day": "雷阵雨",
"condition_night": "雷阵雨",
"temp_day": 32,
"temp_night": 24,
"icon_day": "2",
"icon_night": "2",
"wind_dir_day": "南风",
"wind_dir_night": "西南风",
"sun_rise": 1785445920000,
"sun_set": 1785497400000,
"predict_date": 1785427230000,
"wind_level_day": 2,
"wind_level_night": 2,
"wind_speed_day_real": 2.4,
"wind_speed_night_real": 2.4,
"lunar_date": "丙午年六月十八",
"aqi_desc_short": "优",
"aqi_level": 1,
"aqi_value": 36,
"aqi_desc": "优",
"uvi": "弱",
"humidity": 75,
"pressure": 1002
},
{
"condition_id_day": 4,
"condition_id_night": 4,
"condition_day": "雷阵雨",
"condition_night": "雷阵雨",
"temp_day": 32,
"temp_night": 25,
"icon_day": "2",
"icon_night": "1",
"wind_dir_day": "南风",
"wind_dir_night": "东南风",
"sun_rise": 1785532380000,
"sun_set": 1785583740000,
"predict_date": 1785513630000,
"wind_level_day": 2,
"wind_level_night": 0,
"wind_speed_day_real": 2.4,
"wind_speed_night_real": 0.9,
"lunar_date": "丙午年六月十九",
"aqi_desc_short": "良",
"aqi_level": 2,
"aqi_value": 60,
"aqi_desc": "良",
"uvi": "弱",
"humidity": 77,
"pressure": 1001
}
],
"forecast_hour": [
{
"condition": "多云",
"temperature": 27,
"real_feel": 29,
"humidity": 88,
"wind_speed": "10.116",
"wind_dir": "南风",
"wind_level": "0",
"predict_hour": 1785438000000,
"aqi_value": 36,
"aqi_level": 1,
"aqi_desc": "优",
"comfort_tip": "潮湿",
"wind_text": "微风",
"comfort_tip_2": "适宜",
"uvi_text": "较低"
},
{
"condition": "多云",
"temperature": 27,
"real_feel": 29,
"humidity": 88,
"wind_speed": "13",
"wind_dir": "南风",
"wind_level": "0",
"predict_hour": 1785441600000,
"aqi_value": 38,
"aqi_level": 1,
"aqi_desc": "优",
"comfort_tip": "潮湿",
"wind_text": "微风",
"comfort_tip_2": "适宜",
"uvi_text": "较低"
},
{
"condition": "多云",
"temperature": 26,
"real_feel": 29,
"humidity": 89,
"wind_speed": "7.2",
"wind_dir": "南风",
"wind_level": "0",
"predict_hour": 1785445200000,
"aqi_value": 41,
"aqi_level": 1,
"aqi_desc": "优",
"comfort_tip": "潮湿",
"wind_text": "微风",
"comfort_tip_2": "适宜",
"uvi_text": "较低"
}
],
"index": [
{
"name": "限行",
"status": "尾号",
"level": 1,
"url": "$1/?indexid=1&cityid=33&appshare=1",
"desc": "",
"extra": "5, 0",
"type": 0
},
{
"name": "六月十八",
"status": "万年历",
"level": 2,
"url": "https://html5.moji.com/nb/wnlh5/index.html?channel=speed",
"desc": "$0/index/lunar_v6.png",
"extra": "",
"type": 0
},
{
"name": "闷热",
"status": "穿衣",
"level": 20,
"url": "$1/?indexid=20&cityid=33&appshare=1",
"desc": "$0/index/dress_v6.png",
"extra": "潮湿闷热,衣物排汗透气,手帕擦汗环保时尚,不建议在露天场所逛街。",
"type": 2
}
],
"alert": [],
"updatetime": 1785443154731,
"summary": "北京市,多云,27℃,南风3级,空气优。",
"_cached": true,
"_disclaimer": "数据由墨迹天气提供,仅供参考,不构成专业气象建议;不应用于农业、保险、航运、防灾等决策场景。详细免责声明见 marketplace 详情页。"
},
"request_id": "ms7yrw773bba2d1a",
"tips": "极数本源 · https://apizero.cn"
}城市搜索
本地城市库模糊匹配(中文 / 拼音 / 首字母),返回 id 供实况或历史查询。文档示例为「北京」真实搜索。
https://v1.apizero.cn/api/moji-weather?op=search&keyword=%E5%8C%97%E4%BA%AC&city=%E5%8C%97%E4%BA%AC&limit=5
固定为 search
例search
搜索关键字;也可用 city 传同样含义
例北京
与 keyword 等价的别名参数
例北京
返回条数 1–50,默认 20
例5
| 参数 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| op | string | 是 | 固定为 search | search |
| keyword(关键词) | string | 否 | 搜索关键字;也可用 city 传同样含义 | 北京 |
| city(城市) | string | 否 | 与 keyword 等价的别名参数 | 北京 |
| limit(条数) | integer | 否 | 返回条数 1–50,默认 20 | 5 |
返回结果
实际搜索词
命中数量
城市列表:id / city_id / name / pinyin / parent
id
city_id
名称
pinyin
parent
品牌提示(所有接口统一返回):极数本源 · https://apizero.cn
| 字段 | 类型 | 说明 | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| keyword | string | 实际搜索词 | |||||||||||||||
| count | integer | 命中数量 | |||||||||||||||
| cities | array | 城市列表:id / city_id / name / pinyin / parent | |||||||||||||||
| |||||||||||||||||
| tips | string | 品牌提示(所有接口统一返回):极数本源 · https://apizero.cn | |||||||||||||||
{
"code": 0,
"msg": "成功",
"data": {
"keyword": "北京",
"count": 3,
"cities": [
{
"id": 33,
"city_id": 2,
"name": "北京市",
"pinyin": "beijingshi",
"parent": "北京市"
},
{
"id": 600,
"city_id": 3,
"name": "北京市朝阳区",
"pinyin": "beijingshichaoyangqu",
"parent": "北京市"
},
{
"id": 601,
"city_id": 4,
"name": "北京市通州区",
"pinyin": "beijingshitongzhouqu",
"parent": "北京市"
}
],
"_disclaimer": "数据由墨迹天气提供,仅供参考,不构成专业气象建议;不应用于农业、保险、航运、防灾等决策场景。详细免责声明见 marketplace 详情页。"
},
"request_id": "ms7yrw7h50851c03",
"tips": "极数本源 · https://apizero.cn"
}历史天气
查询已过去日期的真实历史天气。可传 day=YYYY-MM-DD 查单日,或 month=YYYYMM 查整月(当前月为 1 号至昨天)。city 与 id 二选一。文档示例为北京 2026-05-10。
https://v1.apizero.cn/api/moji-weather?op=history&city=%E5%8C%97%E4%BA%AC&id=33&day=2026-05-10&month=202605
固定为 history
例history
城市中文名;与 id 二选一
例北京
城市 internal_id;与 city 二选一
例33
单日:YYYY-MM-DD;或 MM-DD / DD(需配合 month)
例2026-05-10
整月 YYYYMM;不传 day/month 时默认当前月
例202605
| 参数 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| op | string | 是 | 固定为 history | history |
| city(城市) | string | 否 | 城市中文名;与 id 二选一 | 北京 |
| id | integer | 否 | 城市 internal_id;与 city 二选一 | 33 |
| day | string | 否 | 单日:YYYY-MM-DD;或 MM-DD / DD(需配合 month) | 2026-05-10 |
| month | string | 否 | 整月 YYYYMM;不传 day/month 时默认当前月 | 202605 |
返回结果
固定 history
城市信息
id
名称
parent
pinyin
单日查询时的日期 YYYY-MM-DD
所属月份 YYYYMM
单日详情:气温、天气、风力、AQI 等
date
datetime
condition
temp_high
temp_low
wind_dir
wind_level
aqi_value
aqi_level
aqi_desc
icon
整月查询时的逐日列表
items 的一项
单日一句话摘要
品牌提示(所有接口统一返回):极数本源 · https://apizero.cn
| 字段 | 类型 | 说明 | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| mode | string | 固定 history | |||||||||||||||||||||||||||||||||
| city | object | 城市信息 | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
| day | string | 单日查询时的日期 YYYY-MM-DD | |||||||||||||||||||||||||||||||||
| month | string | 所属月份 YYYYMM | |||||||||||||||||||||||||||||||||
| item | object | 单日详情:气温、天气、风力、AQI 等 | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
| items | array | 整月查询时的逐日列表 | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
| summary | string | 单日一句话摘要 | |||||||||||||||||||||||||||||||||
| tips | string | 品牌提示(所有接口统一返回):极数本源 · https://apizero.cn | |||||||||||||||||||||||||||||||||
{
"code": 0,
"msg": "成功",
"data": {
"mode": "history",
"city": {
"id": 33,
"name": "北京市",
"parent": "北京市",
"pinyin": "beijingshi"
},
"day": "2026-05-10",
"month": "202605",
"item": {
"date": "2026-05-10",
"datetime": 1778342400000,
"condition": "多云",
"temp_high": 33,
"temp_low": 15,
"wind_dir": "西北风",
"wind_level": "3",
"aqi_value": 56,
"aqi_level": 2,
"aqi_desc": "良",
"icon": null
},
"summary": "北京市 2026-05-10,多云,15~33℃,西北风3级,AQI 56(良)。",
"_cached": true,
"_disclaimer": "数据由墨迹天气提供,仅供参考,不构成专业气象建议;不应用于农业、保险、航运、防灾等决策场景。详细免责声明见 marketplace 详情页。"
},
"request_id": "ms7yrw7p669da58e",
"tips": "极数本源 · https://apizero.cn"
}请求示例
示例都是服务端写法。Python / JavaScript 各有常规写法和官方库。
curl -sS -H "Authorization: Bearer YOUR_API_KEY" "https://v1.apizero.cn/api/moji-weather?city=%E5%A4%A7%E5%8C%96&id=1205&op=history&keyword=%E5%A4%A7%E5%8C%96&limit=10&day=2026-05-12&month=202604"错误码
先看业务 code。HTTP 也可能不是 200。
成功
参数错误
API Key 无效
API Key 已暂停
当前 IP 不在 Key 白名单
此接口需要 API Key
余额不足
调用过快(QPS)
今日免费额度已用完
接口已下线
接口不存在
服务器内部错误
上游暂时不可用
上游返回格式异常
暂无可用节点
| 业务码 | HTTP | 说明 |
|---|---|---|
| 0 | 200 | 成功 |
| 4000 | 400 | 参数错误 |
| 4011 | 401 | API Key 无效 |
| 4013 | 403 | API Key 已暂停 |
| 4014 | 403 | 当前 IP 不在 Key 白名单 |
| 4015 | 401 | 此接口需要 API Key |
| 4022 | 402 | 余额不足 |
| 4029 | 429 | 调用过快(QPS) |
| 4030 | 429 | 今日免费额度已用完 |
| 4040 | 503 | 接口已下线 |
| 4041 | 404 | 接口不存在 |
| 5000 | 500 | 服务器内部错误 |
| 5020 | 502 | 上游暂时不可用 |
| 5021 | 502 | 上游返回格式异常 |
| 5030 | 502 | 暂无可用节点 |
调用限制
- 计费模式
- 完全免费
- QPS 限制
- QPS 3
- 登录免费额度
- 3000 次(已认证)
- 匿名每日额度
- 1000 次(无 API Key)
- 黄金会员
- 每天 50,000 次 · QPS 10
- 钻石会员
- 每天 100,000 次 · QPS 30
- 企业会员
- 每天 1,000,000 次 · QPS 120
| 计费模式 | 完全免费 |
|---|---|
| QPS 限制 | QPS 3 |
| 登录免费额度 | 3000 次(已认证) |
| 匿名每日额度 | 1000 次(无 API Key) |
| 黄金会员 | 每天 50,000 次 · QPS 10 |
| 钻石会员 | 每天 100,000 次 · QPS 30 |
| 企业会员 | 每天 1,000,000 次 · QPS 120 |
购买套餐、看评价请走商城详情。 购买 / 调试
更新日志
- 1.1.02026-05-15
【重大功能】新增 op=history:查过去某一天/整月的真实历史天气 支持 day=YYYY-MM-DD 单日查询,自动推月份 支持 month=YYYYMM 整月查询;当前月返回 1 号 ~ 昨天,历史月返回完整 30 天 返回字段:当日天气描述 / 高低温 / 风向风力 / AQI;整月还含去年同期、最好/最差空气日 服务端按月缓存:当前月 30 分钟、历史月 24 小时 服务能查到的最早日期约今天往前 40 天
- 1.0.02026-05-14
首次上线 支持城市名 / internal_id / 拼音 / 拼音首字母 检索 实况一次返回:当前天气 + 未来 7 天 + 24 小时 + AQI + 9 项生活指数 + 气象预警 + 农历 服务端 5 分钟缓存,device UID 复用