### [古诗词·一言API免费接口](https://pmself.com/article/2264) **Published:** 2023-06-19T08:30:13 **Author:** eganvi **Excerpt:** 今日诗词API 上线 今日诗词 API 是本 API 的升级版,可以根据不同地点、时间、节日、季节、天气、景观… ### 今日诗词API 上线 今日诗词 API 是本 API 的升级版,可以根据不同地点、时间、节日、季节、天气、景观、城市进行智能推荐古诗词。 官网: [https://www.jinrishici.com/](https://www.jinrishici.com/) 本接口继续保留运营维护。 ### 简介 古诗词·一言API是一个可以随机返回一句古诗词名句的接口。具有以下特点: - 快:使用 Vert.x Java 全异步框架开发,毫秒级稳定响应 - 全:支持 svg / txt / json / png 调用,满足你在任何地方的调用需求 - 多:收录将近10000条古诗词名句 - 准:可以根据你的喜好,在指定的分类中进行随机返回 ### 使用 #### API举例 - [https://v1.jinrishici.com/all.json](https://v1.jinrishici.com/all.json) - [https://v1.jinrishici.com/all.svg](https://v1.jinrishici.com/all.svg) - [https://v1.jinrishici.com/shuqing/libie.png](https://v1.jinrishici.com/shuqing/libie.png) - [https://v1.jinrishici.com/rensheng.txt](https://v1.jinrishici.com/rensheng.txt) #### API地址格式(仅支持https) [https://v1.jinrishici.com/{一级分类}/{二级分类(可选)}.{返回格式(可选)}](https://v1.jinrishici.com/%7B%E4%B8%80%E7%BA%A7%E5%88%86%E7%B1%BB%7D/%7B%E4%BA%8C%E7%BA%A7%E5%88%86%E7%B1%BB\(%E5%8F%AF%E9%80%89\)%7D.%7B%E8%BF%94%E5%9B%9E%E6%A0%BC%E5%BC%8F\(%E5%8F%AF%E9%80%89\)%7D) 查看所有目前支持的分类:[https://v1.jinrishici.com/](https://v1.jinrishici.com/) 目前支持的后缀:.svg .txt .png .json 不加后缀默认返回 json #### SVG 调用 ![](”https://v1.jinrishici.com/all.svg”) SVG后缀是我们推荐的最优调用方案,可以在部分论坛、任何博客、小程序内无损直接调用,并且可以一定程度上控制样式。缺点是部分老旧浏览器不支持。 你可以直接修改svg样式:![](”https://v1.jinrishici.com/all.svg”) 或者使用我们的svg专用的自定义参数 个性化参数 | 说明 | 参数名 | 默认值 | 合法范围 | | --- | --- | --- | --- | | 字体大小(px) | font-size | 20 | \[8,50\] | | 字体间隔(px) | spacing | 1.5 | \[0,30\] | 调用示例![](”https://v1.jinrishici.com/all.svg?font-size=18&spacing=4″) #### JSON 调用 var xhr = new XMLHttpRequest(); xhr.open(‘get’, ‘https://v1.jinrishici.com/all.json’); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { var data = JSON.parse(xhr.responseText); var gushici = document.getElementById(‘gushici’); gushici.innerText = data.content; } }; xhr.send(); JSON调用可以获取来源、作者、分类等信息,可以供你自定义拼接显示效果。 #### PNG 调用 ![](”https://v1.jinrishici.com/all.png”) 我们会提供透明的PNG文件。PNG方法兼容性最好,可以在几乎任何地方插入。并且支持所有浏览器。缺点是不能控制样式,另外,由于流量限制,我们只会给您传送较小的图片源文件。 #### TXT 调用 var xhr = new XMLHttpRequest(); xhr.open(‘get’, ‘https://v1.jinrishici.com/all.txt’); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { var gushici = document.getElementById(‘gushici’); gushici.innerText = xhr.responseText; } }; xhr.send(); TXT调用和JSON调用基本一致,可以节省一些流量。或者,你甚至可以使用 iframe 来调用我们的接口 ### 关于 这是我的个人项目,目的是为了弘扬中国传统文化。 本项目开源并且托管在 Github 上: [https://github.com/xenv/gushici](https://github.com/xenv/gushici) 本人不接受捐助,但恳请不要使用 DDOS 等方法攻击本站。 名句数据由古诗文网收录整理,特此感谢。 若您对本人的其他作品或者文章感兴趣,请访问我的博客:[https://luan.ma](https://luan.ma/) **Tags:** 诗词API **Categories:** 插件&API ---