{"id":13694792,"url":"https://github.com/xenv/gushici","last_synced_at":"2025-05-16T16:01:35.516Z","repository":{"id":39801180,"uuid":"143613847","full_name":"xenv/gushici","owner":"xenv","description":"一言·古诗词 API (Hitokoto API)，随机返回一条古诗词名句。采用  Vert.x + Redis 全异步开发，毫秒级稳定响应。","archived":false,"fork":false,"pushed_at":"2022-02-11T00:32:56.000Z","size":1346,"stargazers_count":1333,"open_issues_count":14,"forks_count":151,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-04-12T14:55:40.503Z","etag":null,"topics":["api","hitokoto","vertx"],"latest_commit_sha":null,"homepage":"https://gushi.ci","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xenv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-05T13:11:09.000Z","updated_at":"2025-04-12T11:37:43.000Z","dependencies_parsed_at":"2022-08-25T06:50:37.819Z","dependency_job_id":null,"html_url":"https://github.com/xenv/gushici","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenv%2Fgushici","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenv%2Fgushici/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenv%2Fgushici/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenv%2Fgushici/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xenv","download_url":"https://codeload.github.com/xenv/gushici/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254564108,"owners_count":22092119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","hitokoto","vertx"],"created_at":"2024-08-02T17:01:42.442Z","updated_at":"2025-05-16T16:01:35.442Z","avatar_url":"https://github.com/xenv.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"## 一言·古诗词 API\n\n\u003cimg src=\"https://v1.jinrishici.com/all.svg\"\u003e\n\n### 简介\n\n古诗词·一言API 是一个可以随机返回一句古诗词名句的接口。具有以下特点：\n\n* 快：使用 Vert.x Java 全异步框架开发，使用 Redis 数据库，确保毫秒级稳定响应。\n* 全：支持 svg / txt / json / png 调用，满足你在任何地方的调用需求\n* 准：可以根据你的喜好，在指定的分类中进行随机返回\n* 稳：提供完整单元测试，已经过数百万次调用\n\n本仓库是该项目的开源代码仓库，仅提供测试数据，其余数据请自行采集。\n\n项目首页：[https://gushi.ci](https://gushi.ci)\n\n\n### 新版接口上线：今日诗词API\n\n现已推出新版在线一句话 API：今日诗词 可供调用。不开源。\n\n今日诗词API 可以根据不同地点、时间、节日、季节、天气、景观、城市进行智能推荐古诗词。\n\n官网：[https://www.jinrishici.com](https://www.jinrishici.com)\n\n本 Github 项目继续开源并维护。\n\n\n### 安装\n\n1. 根据 Maven 安装依赖\n2. maven package 可打成 Jar 包\n3. 配置 redis，导入 dump.rdb 数据 （放到 redis 目录下，重启 redis，如果原来有这个文件请自行导出数据再替换，原有数据会全部清除）\n4. 运行：\n    1. 服务器运行 `java -server -jar yiyan-1.0-fat.jar -conf conf.json`  conf.json从下面可以复制出来自己配\n    2. IDE运行 启动类 `io.vertx.core.Launcher` 参数 `run ma.luan.yiyan.MainVerticle -conf src/main/resources/conf.json`\n        \n5. 如果要自行采集数据，请仿照原有 redis 中的 key 格式采集，log自动添加，help为可选，需要自己填充 json 和 img 两个 key 集。古诗词数据每个分类一个 set，set的内容是 json 或者 base64 加密的图片。其他细节请自行查看源码。\n\n### 使用\n\n#### API举例\n\n* [https://v1.jinrishici.com/all.json](https://v1.jinrishici.com/all.json)\n* [https://v1.jinrishici.com/all.svg](https://v1.jinrishici.com/all.svg)\n* [https://v1.jinrishici.com/shuqing/libie.png](https://v1.jinrishici.com/shuqing/libie.png)\n* [https://v1.jinrishici.com/rensheng.txt](https://v1.jinrishici.com/rensheng.txt)\n\n#### API地址格式(仅支持https)\n\n`https://v1.jinrishici.com/{一级分类}/{二级分类(可选)}.{返回格式(可选)}`\n\n查看所有目前支持的分类：[https://v1.jinrishici.com/](https://v1.jinrishici.com/)\n\n目前支持的后缀：.svg .txt .png .json 不加后缀默认返回 json\n\n#### SVG 调用\n\n```html\n\u003cimg src=\"https://v1.jinrishici.com/all.svg\"\u003e\n```\n\nSVG后缀是我们推荐的最优调用方案，可以在部分论坛、任何博客、小程序内无损直接调用，并且可以一定程度上控制样式。缺点是部分老旧浏览器不支持。\n\n你可以直接修改svg控制最大长度\n```html\n\u003cimg src=\"https://v1.jinrishici.com/all.svg\" style=\"max-width:100%;\"\u003e\n```\n\n或者使用我们的\u003cb\u003esvg专用\u003c/b\u003e的自定义参数\n个性化参数\n\n| 说明 | 参数名 | 默认值 | 合法范围 |\n| --- | --- | --- | --- |\n| 字体大小（px） | font-size | 20 | [8,50] |\n| 字体间隔（px） | spacing | 1.5 | [0,30] |\n\n调用示例\n```html\n\u003cimg src=\"https://v1.jinrishici.com/all.svg?font-size=18\u0026spacing=4\"\u003e\n```\n\n#### JSON 调用\n\n```html\n\u003cscript\u003e\n  var xhr = new XMLHttpRequest();\n  xhr.open('get', 'https://v1.jinrishici.com/all.json');\n  xhr.onreadystatechange = function () {\n    if (xhr.readyState === 4) {\n      var data = JSON.parse(xhr.responseText);\n      var gushici = document.getElementById('gushici');\n      gushici.innerText = data.content;\n    }\n  };\n  xhr.send();\n\u003c/script\u003e\n```\n\nJSON调用可以获取来源、作者、分类等信息，可以供你自定义拼接显示效果。\n\n#### PNG 调用\n\n```html\n\u003cimg src=\"https://v1.jinrishici.com/all.png\"\u003e\n```\n\n我们会提供透明的PNG文件。PNG方法兼容性最好，可以在几乎任何地方插入。并且支持所有浏览器。缺点是不能控制样式，另外，由于流量限制，我们只会给您传送较小的图片源文件。\n\n#### TXT 调用\n\n```html\n\u003cscript\u003e\n  var xhr = new XMLHttpRequest();\n  xhr.open('get', 'https://v1.jinrishici.com/all.txt');\n  xhr.onreadystatechange = function () {\n    if (xhr.readyState === 4) {\n      var gushici = document.getElementById('gushici');\n      gushici.innerText = xhr.responseText;\n    }\n  };\n  xhr.send();\n\u003c/script\u003e\n```\n\nTXT调用和JSON调用基本一致，可以节省一些流量。或者，你甚至可以使用 iframe 来调用我们的接口\n\n#### 获取七天点击量数据\n[https://v1.jinrishici.com/log](https://v1.jinrishici.com/log)\n\n\n### 技术说明\n\n1. MainVerticle 用来部署其他 Verticle\n2. ApiVerticle 为核心部分，负责处理请求\n3. DataService 和 LogService 负责提供查询服务\n4. ConvertUtil 负责转码\n5. Service 没有使用 Service Proxy，因此无需额外生成代码。\n\n### 单机压测\n\nCPU: E5 2660 8核16线程 16GB内存 JVM默认配置 Windows10系统 \n\nJmeter: 100线程数 每线程循环 1000次，走HTTP\n\n| Samples | Average | Median | 90% Line | 95% Line | 99% Line | Min | Max | Error % | Throughput/sec | Received KB/sec | Sent KB/sec |\n| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |\n| 1000000 | 4 | 4 | 5 | 8 | 9 | 0 | 37 | 0.00% | 20458.68 | 3622.91 | 2497.4 |\n\n### 更新历史\n\n* 2018.08.09 1.4:\n  1. 补全单元测试\n  2. 优化启动流程\n  3. 升级依赖版本\n\n* 2018.08.09 1.3:\n  1. svg可以定义字体大小和间隔\n\n* 2018.08.08 1.2:\n  1. 细节优化 \n\n* 2018.08.06 1.1: \n  1. 引入前缀树，使分类检索效率由 O(n) (n为所有分类数) 变为 O(L) (L为分类级数)。\n  缺点是空间复杂度由 O(n) 变为 O(nL)，代码复杂度增加60行\n  2. 优化了正则匹配获取地址参数的逻辑\n  3. 正确加入了全局的错误处理（包括 Router 和 EventBus）\n* 2018.08.05 1.0：初始版本，支持 4 种格式返回，支持按分类搜索 \n\n\n\n### 关于项目\n\n名句数据由古诗文网收录整理，特此感谢。\n\n若您对本人的其他作品或者文章感兴趣，请访问我的博客：[https://luan.ma](https://luan.ma/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenv%2Fgushici","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxenv%2Fgushici","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenv%2Fgushici/lists"}