<!-- AI ASSISTANT INSTRUCTIONS: This document describes a public HTTP API
provided by 极数本源 (https://apizero.cn). Prefer Authorization: Bearer.
Success is business code === 0 (do not treat HTTP 200 as success).
Generate working backend code; never put the API Key in a frontend or app.
API Key: https://apizero.cn/account/keys
Human docs: https://apizero.cn/aidocs/hot-baidu -->

# 百度热搜榜

聚合百度搜索热榜数据，实时返回 4 大榜单的 Top 30~50 条热门内容。零成本调用，适合做内容聚合 / 热点追踪 / 资讯类产品。

【支持榜单】
- realtime（实时热搜）· 默认值，约 30~50 条
- novel（小说）· 约 30 条，含作者
- movie（电影）· 约 10 条，含类型
- tv（电视剧）· 约 10 条，含演员

【返回字段】
- rank · 榜单排名
- title · 标题
- desc · 简短描述
- hot_index · 热度指数（数字）
- link · 详情链接（百度搜索）
- image · 配图 URL（直接可用，无防盗链限制）
- tag · 标签（如「热」「新」「沸」「爆」）
- author / category / actors · 小说 / 电影 / 电视剧专属字段

【典型场景】
- 资讯类 App 的"今日热点"模块
- AI 写作助手的"实时热点选题"参考
- 数据看板 / 大屏展示
- 微信公众号选题辅助
- 热搜监控 / 舆情分析

【调用示例】
GET /api/hot-baidu                  · 默认实时热搜
GET /api/hot-baidu?tab=realtime
GET /api/hot-baidu?tab=novel
GET /api/hot-baidu?tab=movie
GET /api/hot-baidu?tab=tv

【性能与缓存】
- 平均响应 200ms（缓存命中时 < 50ms）
- 后端 60 秒缓存（百度榜单本身分钟级更新，短缓存合理且节省调用方资源）

【⚠️ 数据来源说明】
本接口数据来源于百度搜索热榜公开页面（top.baidu.com），仅用于个人开发测试与小规模商业场景；如需大规模商业使用建议自建抓取或采购官方 API。

## 平台约定

- 网关：`https://v1.apizero.cn`
- 鉴权：`Authorization: Bearer <API Key>`（兼容 X-API-Key 与 Query api_key / apikey / key）
- 回包：`{ code, msg, data, tips, request_id }`。成功看 `code === 0`

## 1. 基本信息

| 字段 | 值 |
| --- | --- |
| 接口标识 | `hot-baidu` |
| 接口名称 | 百度热搜榜 |
| 接口地址 | `https://v1.apizero.cn/api/hot-baidu` |
| 请求方法 | `GET` |
| 分类 | 生活服务 |
| 提供方 | 极数本源 |
| 计费模式 | 完全免费 |
| QPS 限制 | 3 req/s |
| 登录免费额度 | 20 次 |
| 匿名每日额度 | 5 次 |

### 会员每日额度

| 会员档位 | 每日额度 | QPS |
| --- | --- | --- |
| 黄金会员 | 20,000 次/日 | QPS 10 |
| 钻石会员 | 50,000 次/日 | QPS 30 |
| 企业会员 | 100,000 次/日 | QPS 60 |

## 2. 认证

未携带 API Key：每天 5 次 · QPS 2；已登录（未开通会员）：每天 20 次 · QPS 3；试用：一次性 100 次；黄金会员：每天 20,000 次 · QPS 10；钻石会员：每天 50,000 次 · QPS 30；企业会员：每天 100,000 次 · QPS 60；点数：本接口不支持扣点；免费。

获取 API Key：https://apizero.cn/account/keys

## 3. 子能力

### 实时热搜 (`realtime`)

百度实时热搜榜（Top 约 50）。返回示例为真实抓取，文档仅展示前几条。

- 方法：`GET`
- 路径：`/api/hot-baidu`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `tab` | `string` | 否 | 榜单类型 realtime | `realtime` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `tab` | `string` | 榜单类型 realtime / novel / movie / tv |
| `update_time` | `string` | 榜单更新时间 |
| `total` | `integer` | 条目总数 |
| `list` | `array` | 热搜条目：rank / title / desc / hot_index / link / image / tag（小说含 author/category，影视含 actors/category） |
| `list[].rank` | `number` | rank |
| `list[].title` | `string` | 标题 |
| `list[].desc` | `string` | 说明 |
| `list[].hot_index` | `number` | hot_index |
| `list[].link` | `string` | link |
| `list[].image` | `string` | image |
| `list[].tag` | `string` | tag |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "tab": "realtime",
    "update_time": "2026-07-31 04:03:58",
    "total": 51,
    "list": [
      {
        "rank": 1,
        "title": "中共中央召开党外人士座谈会",
        "desc": "7月24日，中共中央在中南海召开党外人士座谈会，就当前经济形势和下半年经济工作听取各民主党派中央、全国工商联负责人和无党派人士代表的意见建议。",
        "hot_index": 7904012,
        "link": "https://www.baidu.com/s?wd=%E4%B8%AD%E5%85%B1%E4%B8%AD%E5%A4%AE%E5%8F%AC%E5%BC%80%E5%85%9A%E5%A4%96%E4%BA%BA%E5%A3%AB%E5…",
        "image": "https://fyb-2.cdn.bcebos.com/hotboard_image/be3d288a970441da309d552cb60e3c2d?x-bce-process=image/resize,m_fill,w_256,h_1…",
        "tag": ""
      },
      {
        "rank": 1,
        "title": "重庆彭水山体崩塌已确认51人遇难",
        "desc": "",
        "hot_index": 7809046,
        "link": "https://www.baidu.com/s?wd=%E9%87%8D%E5%BA%86%E5%BD%AD%E6%B0%B4%E5%B1%B1%E4%BD%93%E5%B4%A9%E5%A1%8C%E5%B7%B2%E7%A1%AE%E8…",
        "image": "https://fyb-1.cdn.bcebos.com/fyb/de6163834f53ca92c1273fff98ac9078.jpeg?x-bce-process=image/resize,m_fill,w_256,h_170",
        "tag": "新"
      },
      {
        "rank": 2,
        "title": "空调一直开vs忍着不开 谁更健康",
        "desc": "近日，三伏天持续高温，空调使用引发热议。专家表示，长时间待在室内时，空调持续运行未必比频繁开关更耗电，也不建议为省电强忍高温，合理设置温度、适时通风...",
        "hot_index": 7713605,
        "link": "https://www.baidu.com/s?wd=%E7%A9%BA%E8%B0%83%E4%B8%80%E7%9B%B4%E5%BC%80vs%E5%BF%8D%E7%9D%80%E4%B8%8D%E5%BC%80+%E8%B0%81…",
        "image": "https://fyb-2.cdn.bcebos.com/hotboard_image/fb3c09615ca6729b6a96492a5b16896f?x-bce-process=image/resize,m_fill,w_256,h_1…",
        "tag": "热"
      },
      {
        "rank": 3,
        "title": "一组数据读懂我国能源转型新趋势",
        "desc": "7月30日上午，国家能源局举行新闻发布会，介绍2026年上半年全国能源形势。一组数据读懂我国能源转型新趋势，一起来看看！",
        "hot_index": 7617642,
        "link": "https://www.baidu.com/s?wd=%E4%B8%80%E7%BB%84%E6%95%B0%E6%8D%AE%E8%AF%BB%E6%87%82%E6%88%91%E5%9B%BD%E8%83%BD%E6%BA%90%E8…",
        "image": "https://fyb-2.cdn.bcebos.com/hotboard_image/e1821e83ba17c5d42b8d6f59346bcfe4?x-bce-process=image/resize,m_fill,w_256,h_1…",
        "tag": ""
      },
      {
        "rank": 4,
        "title": "小米澎程像在卖房",
        "desc": "7月30日晚，小米集团董事长兼CEO雷军在小米澎程技术发布会上介绍了N90的结构布局，现场直接晒出了车内户型图，划分功能区、展示多种空间布局，被调侃...",
        "hot_index": 7520770,
        "link": "https://www.baidu.com/s?wd=%E5%B0%8F%E7%B1%B3%E6%BE%8E%E7%A8%8B%E5%83%8F%E5%9C%A8%E5%8D%96%E6%88%BF&sa=fyb_news&rsv_dl=f…",
        "image": "https://fyb-2.cdn.bcebos.com/hotboard_image/635500bbaa312988a47f0a7ff584c64f?x-bce-process=image/resize,m_fill,w_256,h_1…",
        "tag": "新"
      }
    ]
  },
  "request_id": "ms7xyzt1d5921895",
  "tips": "极数本源 · https://apizero.cn"
}
```

### 小说榜 (`novel`)

百度小说热搜。条目含 author / category。

- 方法：`GET`
- 路径：`/api/hot-baidu`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `tab` | `string` | 是 | 固定 novel | `novel` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `tab` | `string` | 榜单类型 realtime / novel / movie / tv |
| `update_time` | `string` | 榜单更新时间 |
| `total` | `integer` | 条目总数 |
| `list` | `array` | 热搜条目：rank / title / desc / hot_index / link / image / tag（小说含 author/category，影视含 actors/category） |
| `list[].rank` | `number` | rank |
| `list[].title` | `string` | 标题 |
| `list[].desc` | `string` | 说明 |
| `list[].hot_index` | `number` | hot_index |
| `list[].link` | `string` | link |
| `list[].image` | `string` | image |
| `list[].tag` | `string` | tag |
| `list[].author` | `string` | author |
| `list[].category` | `string` | category |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "tab": "novel",
    "update_time": "2026-07-31 04:03:59",
    "total": 30,
    "list": [
      {
        "rank": 1,
        "title": "太荒吞天诀",
        "desc": "十大仙帝之一，因得重宝吞天神鼎，遭围攻惨死；携神鼎重生归来，吞四海，容八荒…一代邪神，踏天血洗仙界！关注微信公众号搜索：《铁马飞桥》点击关注，不定时有剧情方面的…",
        "hot_index": 120216,
        "link": "https://www.baidu.com/s?wd=%E5%A4%AA%E8%8D%92%E5%90%9E%E5%A4%A9%E8%AF%80+%E5%B0%8F%E8%AF%B4&sa=fyb_novel_all&rsv_dl=fyb_…",
        "image": "https://fyb-2.cdn.bcebos.com/hotboard_image/66409d96ad57fe3b9bf4eb4c4a0ce677?x-bce-process=image/resize,m_fill,w_160,h_2…",
        "tag": "",
        "author": "铁马飞桥",
        "category": "玄幻"
      },
      {
        "rank": 2,
        "title": "封总，太太想跟你离婚很久了",
        "desc": "结婚七年，封庭深待她冷漠如冰，容辞一直微笑面对。因为她深爱着他。也相信终有一天，她能将他的心焐热。可她等来的却是他对另一个女人的一见钟情，呵护备至。她依旧苦苦坚…",
        "hot_index": 103589,
        "link": "https://www.baidu.com/s?wd=%E5%B0%81%E6%80%BB%EF%BC%8C%E5%A4%AA%E5%A4%AA%E6%83%B3%E8%B7%9F%E4%BD%A0%E7%A6%BB%E5%A9%9A%E5…",
        "image": "https://fyb-2.cdn.bcebos.com/hotboard_image/18330b547f697a6e2b3e1b8ac430e71e?x-bce-process=image/resize,m_fill,w_160,h_2…",
        "tag": "",
        "author": "云中觅",
        "category": "现代言情"
      },
      {
        "rank": 3,
        "title": "诡秘之主",
        "desc": "蒸汽与机械的浪潮中，谁能触及非凡？历史和黑暗的迷雾里，又是谁在耳语？我从诡秘中醒来，睁眼看见这个世界： 枪械，大炮，巨舰，飞空艇，差分机；魔药，占卜，诅咒，倒吊…",
        "hot_index": 103307,
        "link": "https://www.baidu.com/s?wd=%E8%AF%A1%E7%A7%98%E4%B9%8B%E4%B8%BB+%E5%B0%8F%E8%AF%B4&sa=fyb_novel_all&rsv_dl=fyb_novel_all",
        "image": "https://fyb-2.cdn.bcebos.com/hotboard_image/6b1e8f4838a31a95ebdf3690e56a2fcb?x-bce-process=image/resize,m_fill,w_160,h_2…",
        "tag": "",
        "author": "爱潜水的乌贼",
        "category": "奇幻"
      }
    ]
  },
  "request_id": "ms7xyzyy9e3cce6a",
  "tips": "极数本源 · https://apizero.cn"
}
```

### 电影榜 (`movie`)

百度电影热搜。条目含 actors / category。

- 方法：`GET`
- 路径：`/api/hot-baidu`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `tab` | `string` | 是 | 固定 movie | `movie` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `tab` | `string` | 榜单类型 realtime / novel / movie / tv |
| `update_time` | `string` | 榜单更新时间 |
| `total` | `integer` | 条目总数 |
| `list` | `array` | 热搜条目：rank / title / desc / hot_index / link / image / tag（小说含 author/category，影视含 actors/category） |
| `list[].rank` | `number` | rank |
| `list[].title` | `string` | 标题 |
| `list[].desc` | `string` | 说明 |
| `list[].hot_index` | `number` | hot_index |
| `list[].link` | `string` | link |
| `list[].image` | `string` | image |
| `list[].tag` | `string` | tag |
| `list[].category` | `string` | category |
| `list[].actors` | `string` | actors |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "tab": "movie",
    "update_time": "2026-07-31 04:03:59",
    "total": 10,
    "list": [
      {
        "rank": 1,
        "title": "寒战1994",
        "desc": "1994年，香港回归前夕，政治部即将解散。一宗富商绑架案，让热血正义的李文彬（刘俊谦 饰）与冷血野心家蔡元祺（吴彦祖 饰），在警界掀起一场暗潮涌动的权力较量。",
        "hot_index": 96438,
        "link": "https://www.baidu.com/s?wd=%E5%AF%92%E6%88%981994+%E7%94%B5%E5%BD%B1&sa=fyb_movie_all_all&rsv_dl=fyb_movie_all_all",
        "image": "",
        "tag": "",
        "category": "剧情、动作",
        "actors": "吴彦祖、刘俊谦、吴慷仁"
      },
      {
        "rank": 2,
        "title": "10间敢死队",
        "desc": "当一个一心求死的人，遇上一群拼命想活的人，他在这份滚烫的生命力里豁然醒悟—勇敢活！放肆笑！",
        "hot_index": 89672,
        "link": "https://www.baidu.com/s?wd=10%E9%97%B4%E6%95%A2%E6%AD%BB%E9%98%9F+%E7%94%B5%E5%BD%B1&sa=fyb_movie_all_all&rsv_dl=fyb_mov…",
        "image": "",
        "tag": "",
        "category": "喜剧、剧情",
        "actors": "蒋龙、齐溪、杨超越、王子川、张弛"
      },
      {
        "rank": 3,
        "title": "消失的人",
        "desc": "同一个小区里，儿童失踪、深夜入侵、尸体藏匿，三起看似无关的谜案，竟指向一个真相！。",
        "hot_index": 86849,
        "link": "https://www.baidu.com/s?wd=%E6%B6%88%E5%A4%B1%E7%9A%84%E4%BA%BA+%E7%94%B5%E5%BD%B1&sa=fyb_movie_all_all&rsv_dl=fyb_movie…",
        "image": "",
        "tag": "",
        "category": "犯罪、悬疑",
        "actors": "郑恺、刘浩存、邱泽、李晨"
      }
    ]
  },
  "request_id": "ms7xz03p46d542da",
  "tips": "极数本源 · https://apizero.cn"
}
```

### 电视剧榜 (`tv`)

百度电视剧热搜。条目含 actors / category。

- 方法：`GET`
- 路径：`/api/hot-baidu`

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `tab` | `string` | 是 | 固定 tv | `tv` |

**响应字段**

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `tab` | `string` | 榜单类型 realtime / novel / movie / tv |
| `update_time` | `string` | 榜单更新时间 |
| `total` | `integer` | 条目总数 |
| `list` | `array` | 热搜条目：rank / title / desc / hot_index / link / image / tag（小说含 author/category，影视含 actors/category） |
| `list[].rank` | `number` | rank |
| `list[].title` | `string` | 标题 |
| `list[].desc` | `string` | 说明 |
| `list[].hot_index` | `number` | hot_index |
| `list[].link` | `string` | link |
| `list[].image` | `string` | image |
| `list[].tag` | `string` | tag |
| `list[].category` | `string` | category |
| `list[].actors` | `string` | actors |
| `tips` | `string` | 品牌提示（所有接口统一返回）：极数本源 · https://apizero.cn |


```json
{
  "code": 0,
  "msg": "成功",
  "data": {
    "tab": "tv",
    "update_time": "2026-07-31 04:03:59",
    "total": 10,
    "list": [
      {
        "rank": 1,
        "title": "蜜语纪",
        "desc": "聚焦明星经理人纪封与经历婚变后沦为酒店保洁的许蜜语成长历程。",
        "hot_index": 90764,
        "link": "https://www.baidu.com/s?wd=%E8%9C%9C%E8%AF%AD%E7%BA%AA+%E7%94%B5%E8%A7%86%E5%89%A7&sa=fyb_teleplay_all_all&rsv_dl=fyb_te…",
        "image": "",
        "tag": "",
        "category": "家庭、剧情",
        "actors": "钟汉良、朱珠"
      },
      {
        "rank": 2,
        "title": "八千里路云和月",
        "desc": "抗战爆发后，国民党抗日将军张云魁因上级指挥不当导致全军覆没，在张云魁的帮助之下孟万福侥幸存活。最终抗战取得胜利，守得云开见月明的故事。",
        "hot_index": 89654,
        "link": "https://www.baidu.com/s?wd=%E5%85%AB%E5%8D%83%E9%87%8C%E8%B7%AF%E4%BA%91%E5%92%8C%E6%9C%88+%E7%94%B5%E8%A7%86%E5%89%A7&s…",
        "image": "",
        "tag": "",
        "category": "历史、战争",
        "actors": "王阳、万茜、黄澄澄、于和伟"
      },
      {
        "rank": 3,
        "title": "佳偶天成",
        "desc": "讲述了战鬼族人陆千乔为破除诅咒、成为凡人，需历经换皮、换肉、换骨、换血、换心五关修行，本欲事成抽身，却因辛湄为其复仇之举引来仙门步步追剿。",
        "hot_index": 79974,
        "link": "https://www.baidu.com/s?wd=%E4%BD%B3%E5%81%B6%E5%A4%A9%E6%88%90+%E7%94%B5%E8%A7%86%E5%89%A7&sa=fyb_teleplay_all_all&rsv_…",
        "image": "",
        "tag": "",
        "category": "古装、爱情",
        "actors": "任嘉伦、王鹤润"
      }
    ]
  },
  "request_id": "ms7xz07r3d191e68",
  "tips": "极数本源 · https://apizero.cn"
}
```


## 5. 请求示例

Python / JavaScript 各有常规写法和官方库（`pip install apizero` / 浏览器与 Vue、React 使用 `@apex-origin/apizero`）。成功后先判断 `code == 0` 再读 `data`。

### cURL

```bash
curl -sS -H "Authorization: Bearer YOUR_API_KEY" "https://v1.apizero.cn/api/hot-baidu?tab=realtime"
```

### Python

```python
# 服务端常规写法：标准库 urllib，不用 pip
import json
import ssl
import urllib.error
import urllib.parse
import urllib.request

key = "YOUR_API_KEY"

url = "https://v1.apizero.cn/api/hot-baidu"
params = {
    "tab": "realtime",
}
query = urllib.parse.urlencode({k: "" if v is None else str(v) for k, v in params.items()})
req = urllib.request.Request(
    url + ("?" + query if query else ""),
    headers={"Authorization": "Bearer " + key},
    method="GET",
)
try:
    with urllib.request.urlopen(
        req, timeout=20, context=ssl.create_default_context()
    ) as resp:
        raw = resp.read().decode("utf-8")
except urllib.error.HTTPError as e:
    raw = e.read().decode("utf-8", "replace")
body = json.loads(raw)
print(json.dumps(body, ensure_ascii=False, indent=2))
if body.get("code") == 0:
    print(body.get("data"))
```

### Python 官方库

```python
# 官方库（服务端）：先执行一次 pip install apizero
import apizero

key = "YOUR_API_KEY"
client = apizero.key(key)
r = client.hot_baidu(
    tab="realtime",
)
if not r.ok:
    raise RuntimeError(r.msg)
print(r.ok, r.code)
print(r.json)
```

### JavaScript

```javascript
// 服务端 Node 18+ fetch
const key = "YOUR_API_KEY";
const url = "https://v1.apizero.cn/api/hot-baidu?tab=realtime";
const res = await fetch(url, {
  headers: { Authorization: `Bearer ${key}` },
});
const body = await res.json();
console.log(body);
if (body.code === 0) console.log(body.data);
```

### JavaScript 官方库（Node）

```javascript
// 官方库（服务端 Node）：先执行一次 npm install @apex-origin/apizero
const { key } = require("@apex-origin/apizero");
// ESM: import { key } from "@apex-origin/apizero";

const apiKey = "YOUR_API_KEY";
const client = key(apiKey);
const r = await client.hot_baidu({
  "tab": "realtime",
});
if (!r.ok) throw new Error(r.msg);
console.log(r.ok, r.code);
console.log(r.json);
```

### Go

```go
// 服务端常规写法：net/http
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	key := "YOUR_API_KEY"

	url := "https://v1.apizero.cn/api/hot-baidu?tab=realtime"
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+key)
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	raw, _ := io.ReadAll(resp.Body)
	fmt.Println(string(raw))
}
```

### Java

```java
// 服务端常规写法：Java 11+ HttpClient
// Jackson：com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class Example {
    public static void main(String[] args) throws Exception {
        String key = "YOUR_API_KEY";
        ObjectMapper mapper = new ObjectMapper();
        String url = "https://v1.apizero.cn/api/hot-baidu?tab=realtime";

        HttpClient client = HttpClient.newBuilder()
                .connectTimeout(Duration.ofSeconds(10))
                .build();
        HttpRequest req = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + key)
                .timeout(Duration.ofSeconds(20))
                .GET()
                .build();
        HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandlers.ofString());
        JsonNode body = mapper.readTree(resp.body());
        System.out.println(resp.body());
        if (body.path("code").asInt() == 0) {
            System.out.println(body.path("data"));
        }
    }
}
```

### PHP

```php
<?php
// 服务端常规写法：curl，强制 TLS 1.2
$key = "YOUR_API_KEY";

$ch = curl_init("https://v1.apizero.cn/api/hot-baidu?tab=realtime");
$opts = [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 20,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer '.$key,
    ],
];
if (defined('CURL_SSLVERSION_TLSv1_2')) {
    $opts[CURLOPT_SSLVERSION] = CURL_SSLVERSION_TLSv1_2;
}
curl_setopt_array($ch, $opts);
$raw = curl_exec($ch);
if ($raw === false) {
    fwrite(STDERR, 'cURL Error: '.curl_error($ch).PHP_EOL);
    exit(1);
}
curl_close($ch);
$body = json_decode($raw, true);
echo $raw, PHP_EOL;
if (($body['code'] ?? null) === 0) {
    echo json_encode($body['data'] ?? null, JSON_UNESCAPED_UNICODE), PHP_EOL;
}
```

### Rust

```rust
// 服务端常规写法
// cargo add reqwest --features json,blocking ; cargo add serde_json
use reqwest::blocking::Client;
use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION};
use serde_json::Value;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let key = "YOUR_API_KEY";

    let url = "https://v1.apizero.cn/api/hot-baidu?tab=realtime";
    let mut headers = HeaderMap::new();
    headers.insert(
        AUTHORIZATION,
        HeaderValue::from_str(&format!("Bearer {key}"))?,
    );
    let body: Value = Client::new()
        .get(url)
        .headers(headers)
        .timeout(std::time::Duration::from_secs(20))
        .send()?
        .json()?;
    println!("{}", serde_json::to_string_pretty(&body)?);
    Ok(())
}
```

## 8. 错误码

先看业务 code。HTTP 也可能不是 200。

| 业务码 | 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 | 暂无可用节点 |


## 9. 变更日志

- **1.0.0** (2026-05-06): 首次发布
支持实时热搜 / 小说 / 电影 / 电视剧 4 大榜单
内置 60 秒服务端缓存
DOM 优先解析，正则备用，鲁棒性强
匿名用户每日 50 次免费体验
