[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-94797":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":9,"totalLinesOfCode":9,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":9,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":19,"topics":9,"createdAt":9,"pushedAt":9,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":16,"starSnapshotCount":16,"syncStatus":24,"lastSyncTime":25,"discoverSource":26},94797,"chinese-poetry-api","palemoky\u002Fchinese-poetry-api","palemoky","📜 诗泉：高性能中国古诗词 API 服务",null,"https:\u002F\u002Fgithub.com\u002Fpalemoky\u002Fchinese-poetry-api","Go",2529,308,11,4,0,7,57.17,false,"main","2026-08-24 04:01:22","\u003Cdiv align=\"center\">\n\n\u003Cimg src=\"docs\u002Ficon.png\" alt=\"chinese-poetry\" height=\"100px\">\n\n\u003Ch2>中国古诗词 API 服务\u003C\u002Fh2>\n\n[![Docker Image](https:\u002F\u002Fimg.shields.io\u002Fdocker\u002Fv\u002Fpalemoky\u002Fchinese-poetry-api?sort=semver&label=docker)](https:\u002F\u002Fhub.docker.com\u002Fr\u002Fpalemoky\u002Fchinese-poetry-api)\n[![Docker Image Size](https:\u002F\u002Fimg.shields.io\u002Fdocker\u002Fimage-size\u002Fpalemoky\u002Fchinese-poetry-api\u002Flatest)](https:\u002F\u002Fhub.docker.com\u002Fr\u002Fpalemoky\u002Fchinese-poetry-api)\n[![pre-commit](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fpre--commit-enabled-brightgreen?logo=pre-commit)](https:\u002F\u002Fgithub.com\u002Fpre-commit\u002Fpre-commit)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fpalemoky\u002Fchinese-poetry-api)](https:\u002F\u002Fgithub.com\u002Fpalemoky\u002Fchinese-poetry-api\u002Fblob\u002Fmain\u002FLICENSE)\n\n基于 Go 语言的高性能中国古诗词 API 服务，支持 REST 和 GraphQL 接口，提供简体\u002F繁体中文、爬虫练习场等功能。\n\n在线版：https:\u002F\u002Fpoetry.palemoky.com\n\n\u003C\u002Fdiv>\n\n## 特性\n\n- **高性能**: Go 语言编写，支持并发处理，性能优化（简繁转换 ~300ns\u002Fop）\n- **海量数据**: 包含唐诗、宋词、元曲等近 40 万首诗词\n- **强大搜索**: 支持全文搜索、标题\u002F内容\u002F作者分类搜索\n- **双语支持**: 同一数据库同时存储简体和繁体中文，通过 `?lang=` 参数切换\n- **多种接口**: REST API 和 GraphQL 双接口支持\n- **限流保护**: 内置 IP 限流，防止滥用\n- **容器化**: Docker 镜像开箱即用，支持多架构（amd64\u002Farm64）\n- **智能分类**: 按朝代、作者、诗词类型自动分类\n\n## 快速开始\n\n### 使用 Docker（推荐）\n\n```bash\ndocker run -d -p 1279:1279 palemoky\u002Fchinese-poetry-api:latest\n```\n\n完整配置参见 [docker-compose.yml](docker-compose.yml)。\n\n### 使用 Makefile\n\n```bash\nmake help          # 查看所有可用命令\nmake build         # 构建项目\nmake process-data  # 处理数据\nmake run-server    # 启动服务\n```\n\n### 克隆仓库\n\n本项目使用 Git Submodules 管理诗词数据，推荐使用以下命令快速克隆：\n\n```bash\n# 完整克隆（包含 submodules）\ngit clone --recurse-submodules --depth=1 https:\u002F\u002Fgithub.com\u002Fpalemoky\u002Fchinese-poetry-api.git\n```\n\n如果已经克隆了仓库，可以单独更新 submodules：\n\n```bash\ngit submodule update --init --depth 1\n```\n\n## API 使用\n\n### 多语言支持\n\n所有接口支持 `lang` 参数切换简繁体：\n\n|  参数值   |       说明       |\n| :-------: | :--------------: |\n| `zh-Hans` | 简体中文（默认） |\n| `zh-Hant` |     繁体中文     |\n\n### REST API\n\n```bash\n# 健康检查\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fhealth\"\n\n# 统计信息\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fstats\"\n\n# 简体中文（默认）\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems\"\n\n# 繁体中文\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems?lang=zh-Hant\"\n\n# 诗词列表（带过滤，与 \u002Fpoems\u002Frandom 使用同一组参数）\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems?dynasty=唐\"\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems?author=李白&page=2&page_size=50\"\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems?dynasty_id=1&type_id=11&type_id=12\" # 多个 type_id 为「或」关系\n\n# 参数校验：未知或非法的查询参数返回 400，而不是被忽略\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems?dynastyId=1\"   # 400，未知参数\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems?page_size=500\" # 400，超出上限 100\n\n# 搜索诗词\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems\u002Fsearch?q=静夜思\"\n\n# 随机诗词\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems\u002Frandom\"\n\n# 随机诗词（带过滤）\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems\u002Frandom?author=李白\"\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems\u002Frandom?type=五言绝句\"\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems\u002Frandom?char=春\" # 飞花令等单字场景\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems\u002Frandom?author=李白&type=五言绝句\"\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems\u002Frandom?author=李白&type=五言绝句&dynasty=唐\"\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fpoems\u002Frandom?author=李白&dynasty=唐&type=五言绝句&type=七言绝句&type=五言律诗\"\n\n# 作者列表\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fauthors?page=1&page_size=20\"\n\n# 作者详情\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fauthors\u002F1\"\n\n# 朝代列表\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fdynasties\"\n\n# 朝代详情\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Fdynasties\u002F1\"\n\n# 诗词体裁列表\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Ftypes\"\n\n# 诗词体裁详情\ncurl \"http:\u002F\u002Flocalhost:1279\u002Fapi\u002Fv1\u002Ftypes\u002F10\"\n```\n\n### GraphQL API\n\n端点：`http:\u002F\u002Flocalhost:1279\u002Fgraphql`\n\n```graphql\n# 繁体中文查询\nquery {\n  poems(lang: ZH_HANT, pageSize: 10) {\n    edges {\n      node {\n        title\n        content\n        author {\n          name\n        }\n      }\n    }\n    totalCount\n  }\n}\n\n# 搜索诗词\nquery {\n  searchPoems(query: \"静夜思\", searchType: TITLE) {\n    edges {\n      node {\n        title\n        author {\n          name\n        }\n      }\n    }\n  }\n}\n\n# 统计信息\nquery {\n  statistics {\n    totalPoems\n    totalAuthors\n    poemsByDynasty {\n      dynasty {\n        name\n      }\n      count\n    }\n  }\n}\n```\n\n## 搜索功能\n\n|   类型    |       说明       |             示例             |\n| :-------: | :--------------: | :--------------------------: |\n|   `all`   | 全文搜索（默认） |           `?q=月`            |\n|  `title`  |     标题搜索     |    `?q=静夜思&type=title`    |\n| `content` |     内容搜索     | `?q=床前明月光&type=content` |\n| `author`  |     作者搜索     |    `?q=李白&type=author`     |\n\n## 数据集\n\n本项目基于 [chinese-poetry](https:\u002F\u002Fgithub.com\u002Fchinese-poetry\u002Fchinese-poetry) 数据集，包含：\n\n|   分类   |  数量  |   分类   |  数量  |   分类   |  数量  |   分类   |  数量  |\n| :------: | :----: | :------: | :----: | :------: | :----: | :------: | :----: |\n| 五言绝句 | 18,895 | 七言绝句 | 85,032 | 五言律诗 | 71,400 | 七言律诗 | 69,028 |\n|  乐府诗  | 9,315  |  五代词  |  543   |   宋词   | 21,369 |   元曲   | 10,905 |\n|   诗经   |  305   |   楚辞   |   65   |   论语   |   20   | 四书五经 |   14   |\n|   其他   | 96,232 |          |        |          |        |          |        |\n\n```mermaid\npie title 收录数据分布概览 (忽略极小值)\n\"七绝\u002F七律\" : 154060\n\"五绝\u002F五律\" : 90295\n\"宋词\u002F五代词\" : 21912\n\"元曲\" : 10905\n\"乐府诗\" : 9315\n\"其他\" : 96232\n```\n\n## 致谢\n\n- 数据来源：[chinese-poetry](https:\u002F\u002Fgithub.com\u002Fchinese-poetry\u002Fchinese-poetry)\n- 简繁转换：[gocc](https:\u002F\u002Fgithub.com\u002Fliuzl\u002Fgocc)\n","诗泉（chinese-poetry-api）是一个基于 Go 实现的高性能中国古诗词 REST\u002FGraphQL API 服务。它提供近 40 万首唐诗、宋词、元曲等古典文学作品的结构化访问，支持简繁体自动切换、多维度过滤（朝代\u002F作者\u002F体裁）、全文与关键词搜索、随机诗词抽取及 IP 限流保护，并通过 Docker 容器化部署，开箱即用。适用于诗词学习类 App、教育平台、文化类网站后端、飞花令等互动功能开发，以及中文 NLP 数据源或爬虫练习场景。",2,"2026-08-16 02:30:05","trending"]