接口列表
以下路径均相对于 BASE URL https://www.shicidi.com/api/v1。
返回站点全部诗词分类(唐诗、宋词、元曲、诗经等),含分类简介、收录数量与对应页面地址。数据变化不频繁,适合本地缓存。
该端点无需请求参数。
响应示例
{
"code": 0,
"message": "ok",
"data": {
"list": [
{
"id": 1,
"name": "唐诗",
"slug": "tangshi",
"dynasty": "唐",
"intro": "唐诗泛指创作于唐代的诗,是中华诗词的高峰……",
"poem_count": 57590,
"url": "https://www.example.com/list/tangshi/"
}
],
"total": 19
},
"request_id": "9c3f1b7d2a4e5f60"
}
分页获取诗人/作者列表,可按朝代、姓名关键词、存诗数筛选,默认按存诗数量倒序。
请求参数
| 参数 | 类型 | 必填 | 说明 |
page |
int |
否 |
页码,默认 1 |
per_page |
int |
否 |
每页条数,默认 20,最大 100 |
dynasty |
string |
否 |
朝代,如 唐、宋、先秦 |
keyword |
string |
否 |
姓名或拼音模糊匹配,如 李白 / libai |
min_poems |
int |
否 |
存诗数量下限,如 100 |
sort |
string |
否 |
poems(默认,按存诗数)/ id / name |
响应示例
{
"code": 0,
"message": "ok",
"data": {
"list": [
{
"id": 105,
"name": "李白",
"pinyin": "li bai",
"slug": "libai",
"dynasty": "唐",
"poem_count": 1015,
"has_intro": 1,
"url": "https://www.example.com/shiren/libai.html"
}
],
"pagination": { "page": 1, "per_page": 20, "total": 13651, "pages": 683 }
},
"request_id": "9c3f1b7d2a4e5f60"
}
按作者 ID、拼音 slug 或姓名获取作者详情,包含完整小传,并附带该作者前 5 首作品,常见场景一次请求即可渲染作者页。
请求参数
| 参数 | 类型 | 必填 | 说明 |
id |
string |
是 |
路径参数:作者 ID、slug 或姓名,如 105 / libai / 李白 |
响应示例
{
"code": 0,
"message": "ok",
"data": {
"author": {
"id": 105,
"name": "李白",
"pinyin": "li bai",
"slug": "libai",
"dynasty": "唐",
"poem_count": 1015,
"has_intro": 1,
"intro": "李白(701—762),字太白,号青莲居士,唐代浪漫主义诗人……",
"intro_excerpt": "李白(701—762),字太白,号青莲居士……",
"url": "https://www.example.com/shiren/libai.html"
},
"poems_preview": [
{
"id": 1203,
"title": "静夜思",
"author": { "id": 105, "name": "李白", "slug": "libai" },
"dynasty": "唐",
"category": { "id": 1, "name": "唐诗", "slug": "tangshi" },
"first_line": "床前明月光",
"excerpt": "床前明月光,疑是地上霜。",
"char_count": 20,
"line_count": 4,
"is_featured": 1,
"rhythmic": "",
"section": "",
"url": "https://www.example.com/shi/1203.html"
}
],
"links": {
"poems": "/api/v1/authors/105/poems",
"page": "https://www.example.com/shiren/libai.html"
}
},
"request_id": "9c3f1b7d2a4e5f60"
}
GET
/authors/{id}/poems
作者作品列表
获取某位作者的全部作品,分页返回。参数与「诗词列表」一致(category 等筛选可叠加)。
请求参数
| 参数 | 类型 | 必填 | 说明 |
id |
string |
是 |
路径参数:作者 ID、slug 或姓名 |
page |
int |
否 |
页码,默认 1 |
per_page |
int |
否 |
每页条数,默认 20,最大 100 |
sort |
string |
否 |
id(默认)/ new / short / long |
with_content |
int |
否 |
传 1 返回正文全文(默认仅摘要) |
响应示例
{
"code": 0,
"message": "ok",
"data": {
"list": [
{
"id": 1203,
"title": "静夜思",
"author": { "id": 105, "name": "李白", "slug": "libai" },
"excerpt": "床前明月光,疑是地上霜。",
"char_count": 20,
"url": "https://www.example.com/shi/1203.html"
}
],
"pagination": { "page": 1, "per_page": 20, "total": 1015, "pages": 51 },
"author": { "id": 105, "name": "李白", "slug": "libai", "poem_count": 1015 }
},
"request_id": "9c3f1b7d2a4e5f60"
}
核心列表接口。支持按分类、作者、朝代、精选、关键词组合筛选与多种排序,默认返回摘要,传 with_content=1 返回全文。
请求参数
| 参数 | 类型 | 必填 | 说明 |
page |
int |
否 |
页码,默认 1 |
per_page |
int |
否 |
每页条数,默认 20,最大 100 |
category |
string |
否 |
分类 slug 或 ID,如 tangshi / 1 |
category_id |
int |
否 |
分类 ID(与 category 二选一) |
author_id |
int |
否 |
作者 ID |
author |
string |
否 |
作者 ID / slug / 姓名,如 李白 |
dynasty |
string |
否 |
朝代,如 唐 |
featured |
int |
否 |
1 仅精选作品,0 仅非精选 |
keyword |
string |
否 |
标题 / 作者 / 正文关键词,最多 30 字 |
sort |
string |
否 |
id(默认,按收录顺序)/ new(最新)/ short(短篇优先)/ long(长篇优先) |
with_content |
int |
否 |
传 1 时列表项包含 content 与 lines 全文 |
响应示例
{
"code": 0,
"message": "ok",
"data": {
"list": [
{
"id": 1203,
"title": "静夜思",
"author": { "id": 105, "name": "李白", "slug": "libai" },
"dynasty": "唐",
"category": { "id": 1, "name": "唐诗", "slug": "tangshi" },
"rhythmic": "",
"section": "",
"first_line": "床前明月光",
"excerpt": "床前明月光,疑是地上霜。",
"char_count": 20,
"line_count": 4,
"is_featured": 1,
"url": "https://www.example.com/shi/1203.html"
}
],
"pagination": { "page": 1, "per_page": 20, "total": 57590, "pages": 2880 }
},
"request_id": "9c3f1b7d2a4e5f60"
}
按 ID 获取单篇作品的完整内容:原文分行、逐行拼音、注释、白话译文、赏析、作者简介、所属分类以及上下篇。
请求参数
| 参数 | 类型 | 必填 | 说明 |
id |
int |
是 |
路径参数:作品 ID,如 1203 |
响应示例
{
"code": 0,
"message": "ok",
"data": {
"id": 1203,
"title": "静夜思",
"author": {
"id": 105,
"name": "李白",
"slug": "libai",
"pinyin": "li bai",
"dynasty": "唐",
"poem_count": 1015,
"has_intro": 1,
"intro": "李白(701—762),字太白,号青莲居士……",
"url": "https://www.example.com/shiren/libai.html"
},
"dynasty": "唐",
"category": { "id": 1, "name": "唐诗", "slug": "tangshi", "dynasty": "唐", "url": "https://www.example.com/list/tangshi/" },
"content": "床前明月光\n疑是地上霜\n举头望明月\n低头思故乡",
"lines": ["床前明月光", "疑是地上霜", "举头望明月", "低头思故乡"],
"pinyin": "chuang qian ming yue guang|yi shi di shang shuang|ju tou wang ming yue|di tou si gu xiang",
"pinyin_lines": ["chuang qian ming yue guang", "yi shi di shang shuang", "ju tou wang ming yue", "di tou si gu xiang"],
"notes": "① 静夜思:安静的夜晚产生的思绪。",
"notes_lines": ["① 静夜思:安静的夜晚产生的思绪。"],
"translation": "明亮的月光洒在床前,好像地上泛起了一层白霜……",
"translation_lines": ["明亮的月光洒在床前,好像地上泛起了一层白霜……"],
"appreciation": "这首诗写的是在寂静的月夜思念家乡的感受……",
"appreciation_lines": ["这首诗写的是在寂静的月夜思念家乡的感受……"],
"first_line": "床前明月光",
"excerpt": "床前明月光,疑是地上霜。",
"char_count": 20,
"line_count": 4,
"is_featured": 1,
"rhythmic": "",
"section": "",
"url": "https://www.example.com/shi/1203.html",
"prev": { "id": 1202, "title": "…", "url": "https://www.example.com/shi/1202.html" },
"next": { "id": 1204, "title": "…", "url": "https://www.example.com/shi/1204.html" }
},
"request_id": "9c3f1b7d2a4e5f60"
}
按标题、作者或诗句全文检索作品。有 ngram 全文索引时走索引,否则自动退化为 LIKE,结果均为分页。
请求参数
| 参数 | 类型 | 必填 | 说明 |
keyword |
string |
是 |
检索关键词,最多 30 字 |
type |
string |
否 |
all(默认)/ title / author / content |
category |
string |
否 |
限定分类 slug 或 ID |
page |
int |
否 |
页码,默认 1 |
per_page |
int |
否 |
每页条数,默认 20,最大 100 |
with_content |
int |
否 |
传 1 返回正文全文 |
响应示例
{
"code": 0,
"message": "ok",
"data": {
"keyword": "静夜思",
"type": "all",
"list": [
{
"id": 1203,
"title": "静夜思",
"author": { "id": 105, "name": "李白", "slug": "libai" },
"excerpt": "床前明月光,疑是地上霜。",
"url": "https://www.example.com/shi/1203.html"
}
],
"pagination": { "page": 1, "per_page": 20, "total": 37, "pages": 2 }
},
"request_id": "9c3f1b7d2a4e5f60"
}
返回站点收录总量、分类分布与更新时间,适合做首页数据面板或健康监控。
该端点无需请求参数。
响应示例
{
"code": 0,
"message": "ok",
"data": {
"totals": { "poems": 345614, "authors": 13651, "categories": 19, "featured": 1200 },
"categories": [
{ "id": 1, "name": "唐诗", "slug": "tangshi", "dynasty": "唐", "poem_count": 57590 }
],
"imported_at": "2026-10-30 12:21:09",
"site": {
"name": "中国古诗网",
"slogan": "诗者,志之所之也",
"url": "https://www.example.com"
}
},
"request_id": "9c3f1b7d2a4e5f60"
}
免鉴权端点,用于连通性测试与监控探活,不消耗调用配额。
该端点无需请求参数。
响应示例
{
"code": 0,
"message": "ok",
"data": {
"status": "ok",
"time": "2026-11-03T14:20:31+08:00",
"api": "v1",
"site": "中国古诗网"
},
"request_id": "9c3f1b7d2a4e5f60"
}
调用示例
curl
curl "https://www.shicidi.com/api/v1/poems?category=tangshi&per_page=5" \
-H "X-API-Key: gsc_你的密钥"
JavaScript(浏览器 / Node 18+)
const res = await fetch("https://www.shicidi.com/api/v1/authors?keyword=李白", {
headers: { "X-API-Key": "gsc_你的密钥" }
});
const json = await res.json();
if (json.code !== 0) throw new Error(json.message);
console.log(json.data.list, json.data.pagination);
PHP
$ch = curl_init("https://www.shicidi.com/api/v1/poems/1203");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["X-API-Key: gsc_你的密钥"],
]);
$json = json_decode(curl_exec($ch), true);
curl_close($ch);
if (($json['code'] ?? -1) === 0) {
echo $json['data']['title']; // 静夜思
echo $json['data']['translation'];
}
Python
import requests
r = requests.get("https://www.shicidi.com/api/v1/search",
params={"keyword": "静夜思", "per_page": 3},
headers={"X-API-Key": "gsc_你的密钥"},
timeout=10)
data = r.json()
for item in data["data"]["list"]:
print(item["id"], item["title"], item["author"]["name"])