接口一览
| 接口 | 说明 |
GET /api/ | 随机返回一句(全部分类) |
GET /api/{分类}/ | 只返回指定分类的一句 |
GET /docs/ | 本文档(页面) |
GET / | 一言展示页(人看的) |
分类表
| 英文分类 | 中文 | 示例 |
animation | 动画 | /api/animation/ |
comic | 漫画 | /api/comic/ |
game | 游戏 | /api/game/ |
literature | 文学 | /api/literature/ |
original | 原创 | /api/original/ |
internet | 来自网络 | /api/internet/ |
other | 其他 | /api/other/ |
movie | 影视 | /api/movie/ |
poetry | 诗词 | /api/poetry/ |
netease | 网易云 | /api/netease/ |
philosophy | 哲学 | /api/philosophy/ |
wit | 抖机灵 | /api/wit/ |
请求参数
| 参数 | 说明 | 示例 |
max_length | 句子最大长度(0-1000,默认 30) | /api/poetry/?max_length=20 |
min_length | 句子最小长度 | /api/?min_length=10 |
encode | 返回编码:json(默认)/ text(纯文本)/ js | /api/?encode=text |
返回格式(JSON)
{
"id": 9636, // 句子 ID
"uuid": "4195eeb3-...", // 全局唯一标识
"hitokoto": "钱都流向不缺钱的人…", // 句子内容
"type": "l", // 分类字母
"from": "弱智吧", // 出处
"from_who": null, // 作者
"creator": "huangyx", // 投稿人
"created_at": "1702221224" // 创建时间戳
}
调用示例
curl
# 随机一句(全部分类)
curl https://hitokoto.n.icu/api/
# 只要诗词,20 字以内
curl "https://hitokoto.n.icu/api/poetry/?max_length=20"
JavaScript
fetch('https://hitokoto.n.icu/api/movie/')
.then(r => r.json())
.then(d => console.log(d.hitokoto, '——', d.from));
Python
import requests
r = requests.get('https://hitokoto.n.icu/api/poetry/').json()
print(r['hitokoto'], '——', r['from'])
服务说明
免费开放
本项目基于 hitokoto-osc/hitokoto-api 开源项目自建,句子数据来自 hitokoto.cn 开源库(10000+ 条)。
请合理使用,高频调用请自建或联系站长。