> ## Documentation Index
> Fetch the complete documentation index at: https://docs.api.ecylt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 二次元论坛一言（hitokoto）

> 调用二次元论坛一言 API 服务

<Info>
  如果您喜欢该接口并想支持该接口继续运行，请[赞助我们](https://afdian.com/a/wxs1546)，十分感谢！
</Info>

## API 端点

`BaseURL`: `https://hitokoto-api.ecylt.com`

### 1. 获取随机一言

```http theme={null}
GET /api/hitokoto
```

返回一条随机的一言。

#### 响应示例

```json theme={null}
{
  "id": 1,
  "content": "生命不息，奋斗不止",
  "source": "网络",
  "category": "f"
}
```

### 2. 按类别获取一言

```http theme={null}
GET /api/hitokoto/{category}
```

返回指定类别的随机一言。

#### 参数

| 参数       | 类型     | 说明                                                |
| -------- | ------ | ------------------------------------------------- |
| category | string | 一言的类别，可选值：<br />- e: 原创(包含坛友贡献的一言)<br />- f: 来自网络 |

#### 响应示例

```json theme={null}
{
  "id": 2,
  "content": "人生最大的遗憾，就是在最无能为力的时候遇到一个想要保护一生的人",
  "source": "我们仍未知道那天所看见的花的名字",
  "category": "f"
}
```

#### 错误响应

当类别无效时：

```json theme={null}
{
  "error": "Invalid category"
}
```

当找不到对应类别的语句时：

```json theme={null}
{
  "error": "No sentences found for this category"
}
```
