指南 · 快速开始
快速开始
用一条 curl 请求读取烟雨庭的公开内容. 不需要 SDK,也不需要先注册账号.
开始之前
你需要一个能发 HTTP 请求的工具. 下面的示例使用 curl,Windows、macOS 和 Linux 都可以安装. 公开读接口不需要登录;只有控制台和 API Key 管理需要 YanYuTing Passport.
只读接口
内容 API 只允许 GET/HEAD,只返回已发布且发布时间不晚于当前时间的内容. 写操作由 team 后端携带内部密钥调用,不对外开放.
Base URL
生产环境固定使用下面的地址. 本文档中的路径都相对于它.
https://api.mcyyt.cn
第一次请求
读取新闻列表,按发布时间倒序,取第一页 5 条.
curl -s "https://api.mcyyt.cn/v1/content?kind=news&page=1&page_size=5" \
-H "Accept: application/json"
响应示例(省略了部分字段):
{
"code": 0,
"msg": "ok",
"data": {
"items": [
{
"id": "7f3f0f2e-...",
"slug": "server-update-2026-11",
"kind": "news",
"title": "服务器更新公告",
"summary": "本周维护与更新内容.",
"cover_url": null,
"cover_alt": null,
"tags": [
{"name": "公告", "slug": "announcement", "color": "#ef5777"}
],
"author_name": "YanYuTing",
"published_at": "2026-11-14T08:00:00Z",
"updated_at": "2026-11-14T08:00:00Z",
"is_top": false,
"views": 0,
"likes": 0,
"comments_count": 0,
"url": "https://www.mcyyt.cn/news/server-update-2026-11"
}
],
"page": 1,
"page_size": 10,
"total": 1,
"total_pages": 1
},
"requestId": "req_01..."
}
如果参数合法但列表为空,code 仍然是 0,data.items 是空数组. 不要用 HTTP 200 判断“有内容”.
常用查询参数
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
kind | string | 全部 | news、announcement 或 post |
page | integer | 1 | 从 1 开始 |
page_size | integer | 10 | 1-50 |
tag | string | 空 | 标签 slug |
q | string | 空 | 标题或摘要关键词 |
sort | string | published | published、views 或 updated |
读取详情
列表项里的 id 或 slug 都可以用于详情接口. 详情响应额外包含正文 HTML、SEO 字段和上一篇/下一篇.
curl -s "https://api.mcyyt.cn/v1/content/server-update-2026-11"
公开详情不会增加浏览量. 未发布、已删除或不存在的内容统一返回 404,不区分具体原因.
带上 API Key
如果需要一个独立的调用身份和调用统计,在 控制台 创建 API Key,然后放进请求头.
curl -s "https://api.mcyyt.cn/v1/content?kind=announcement" \
-H "Authorization: Bearer mcyyt_xxxxxxxxxxxxxxxx"
不要把 Key 放进前端代码
浏览器里发出的请求会暴露所有请求头. API Key 只应放在服务端、构建脚本或本地环境变量中.
下一步
- 认证与 API Key:权限范围、登录流程和 CSRF.
- 错误处理:429、5xx 和重试.
- 内容 API:完整字段和示例.
- 服务器状态:轮询在线人数.