跳到主要内容

开发者文档

API 文档

名言云 QuoteAPI 采用 RESTful 风格,统一前缀 /api/v1 ,统一 JSON 响应格式。

基础路径

https://my.lequ.pw/api/v1

内容类型

application/json

字符编码

UTF-8

鉴权方式

API Key

名言调用

1 个接口

GET /api/v1/quote/random

随机名言

随机返回一条名言。返回的 JSON 字段可自行编排展示。

鉴权:API Key 计费:是(每次调用计 1 次)

效果演示

点击按钮体验真实接口返回效果,每 IP 每小时限 20 次。

请求示例

cURL
curl -X GET "https://my.lequ.pw/api/v1/quote/random" \
  -H "X-API-Key: sk-xxxxxxxxxxxx"

响应示例

response
{
  "code": 200,
  "message": "success",
  "data": {
    "id": 22,
    "category": "名人名言",
    "content": "千里之行,始于足下。",
    "author": "老子",
    "source": "道德经",
    "tags": ["行动", "坚持", "积累"]
  },
  "meta": {
    "provider": "杰哥",
    "provider_url": "https://my.lequ.pw",
    "remaining_today": 87
  }
}

历史上的今天

1 个接口

GET /api/v1/history/today

今日历史

随机返回今日历史事件,最多 10 条。

鉴权:API Key 计费:是(每次调用计 1 次)

效果演示

点击按钮体验真实接口返回效果,每 IP 每小时限 20 次。

请求示例

cURL
curl -X GET "https://my.lequ.pw/api/v1/history/today" \
  -H "X-API-Key: sk-xxxxxxxxxxxx"

响应示例

response
{
  "code": 200,
  "message": "success",
  "data": [
    {
      "id": 28500,
      "year": "1969",
      "year_int": 1969,
      "era": "公元",
      "month": 7,
      "day": 16,
      "type": 1,
      "type_name": "大事件",
      "content": "阿波罗11号发射升空,人类首次登月任务启动。"
    },
    {
      "id": 16036,
      "year": "1764",
      "year_int": 1764,
      "era": "公元",
      "month": 7,
      "day": 16,
      "type": 3,
      "type_name": "逝世",
      "content": "伊凡六世,俄罗斯帝国的皇帝。"
    }
  ],
  "pagination": { "page": 1, "page_size": 10, "total": 75 },
  "meta": {
    "provider": "杰哥",
    "provider_url": "https://my.lequ.pw",
    "remaining_today": 87,
    "date": "2026-07-16"
  }
}

数据编排示例

返回的 JSON 字段可自由组合展示

API 返回的结构化数据,你可以根据业务需要自行编排展示格式。以下以名言和历史事件为例:

名言数据编排

原始 JSON 字段 → 自由组合展示

原始字段

response.data
{
  "category": "名人名言",
  "content": "千里之行,始于足下。",
  "author": "老子",
  "source": "道德经",
  "tags": ["行动", "坚持", "积累"]
}

编排效果

简洁式

千里之行,始于足下。 — 老子

完整式

千里之行,始于足下。

—— 老子《道德经》

#行动 #坚持 #积累

JavaScript 示例

编排代码
// 从返回数据中提取字段,自由拼接
const { content, author, source, tags } = response.data;

// 简洁式:千里之行,始于足下。 — 老子
const simple = `${content} — ${author}`;

// 完整式:千里之行,始于足下。—— 老子《道德经》
const full = `${content}\n—— ${author}《${source}》`;

// 标签式:千里之行,始于足下。 #行动 #坚持 #积累
const tagged = `${content} ${tags.map(t => '#' + t).join(' ')}`;

历史数据编排

返回数组 → 逐条编排展示

原始字段

response.data[0]
{
  "year": "1969",
  "year_int": 1969,
  "era": "公元",
  "type": 1,
  "type_name": "大事件",
  "content": "阿波罗11号发射升空..."
}

编排效果

时间线式

1969年 · 大事件

阿波罗11号发射升空...

卡片式

大事件 1969

阿波罗11号发射升空...

JavaScript 示例

编排代码
// 遍历历史数组,逐条编排
response.data.forEach(event => {
  // 时间线式:1969年 · 大事件
  const timeline = `${event.year_int}年 · ${event.type_name}`;

  // 卡片式:[大事件] 1969 - 阿波罗11号发射升空...
  const card = `[${event.type_name}] ${event.year} - ${event.content}`;

  // 带公元/公元前:公元1969年 - 阿波罗11号...
  const withEra = `${event.era}${event.year_int}年 - ${event.content}`;
});

状态码与错误

统一错误响应格式

状态码 含义
200 成功
201 创建成功
400 请求参数错误
401 未认证 / Token 无效 / API Key 无效
403 无权限(非管理员)
404 资源不存在
429 调用次数超限
500 服务器内部错误

配额超限响应示例(429)

error response
{
  "code": 429,
  "message": "今日调用次数已用完,该服务由杰哥提供,升级会员解锁更多次数",
  "data": null,
  "upgrade_url": "https://my.lequ.pw/pricing"
}