# 语法核查

> 会员内测

`POST https://paperpurr.com/v1/check`

检查英文文本的语法、拼写、标点和精简，可以自动采纳高把握的更正。引语、引用、链接、代码和参考文献表不会改动。

## 请求参数

- `text` (string，必填) — 英文文本，最多 10000 词
- `auto_apply` (boolean，默认 true) — `false` 时只列建议，`text` 原样返回
- `level` (string，默认 all) — `all`：语法、拼写、精简和缩写；`correctness`：只管语法和拼写。
- `dialect` (string，默认 us) — `us` 或 `uk`

## 请求示例

curl:

```bash
curl -X POST "https://paperpurr.com/v1/check" \
  -H "Authorization: Bearer $PAPERPURR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"The results shows that the workshop helped. In order to test this, we has run a second survey.","auto_apply":true}'
```

Python:

```python
import os
import requests

r = requests.post(
    "https://paperpurr.com/v1/check",
    headers={"Authorization": f"Bearer {os.environ['PAPERPURR_API_KEY']}"},
    json={
        "text": "The results shows that the workshop helped. In order to test this, we has run a second survey.",
        "auto_apply": true
    },
)
print(r.json())
```

JS:

```javascript
const r = await fetch("https://paperpurr.com/v1/check", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.PAPERPURR_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "text": "The results shows that the workshop helped. In order to test this, we has run a second survey.",
    "auto_apply": true
  }),
});
console.log(await r.json());
```

## 响应

```json
{
  "text": "The results show that the workshop helped. To test this, we have run a second survey.",
  "corrections": [
    {
      "before": "has",
      "after": "have",
      "category": "correctness",
      "rule": "Agreement",
      "message": "The form of the verb must agree in grammatical number with the pronoun.",
      "sentence": "In order to test this, we has run a second survey."
    },
    {
      "before": "In order to",
      "after": "To",
      "category": "clarity",
      "rule": "wordy-phrase",
      "message": "This phrase can be said in fewer words.",
      "sentence": "In order to test this, we have run a second survey."
    },
    {
      "before": "shows",
      "after": "show",
      "category": "correctness",
      "rule": "subject-verb",
      "message": "The subject and the verb don’t agree in number.",
      "sentence": "The results shows that the workshop helped."
    }
  ],
  "suggestions": [],
  "suggestions_total": 0,
  "words": 18,
  "request_id": "req_3b7e05c2f8a14d96b0e3c5a7"
}
```

- `text` (string，必填) — 更正后的文本
- `corrections` (object[]，必填) — 已采纳的更正，字段同[自然改写](https://paperpurr.com/docs/rewrite)
- `suggestions` (object[]，必填) — 没有自动采纳的建议，最多 40 条
  - `text` (string，必填) — 有问题的片段
  - `replacements` (string[]，必填) — 可替换成什么；空字符串表示删掉
  - `sentence` (string) — 所在的句子
  - `category` (string，必填) — 类别，如 `correctness`、`clarity`
  - `rule` (string，必填) — 规则名
  - `message` (string，必填) — 原因，英文
- `suggestions_total` (integer，必填) — 建议总数，可能多于返回的条数
- `words` (integer，必填) — 提交的词数
- `request_id` (string，必填) — 请求 ID

> **建议：** 已经润色过的终稿用 `auto_apply: false`，逐条决定要不要改。

## 可能的错误

| 状态码 | code | 原因 | 怎么处理 |
| --- | --- | --- | --- |
| `400` | `missing_parameter` | 缺少必填参数，`param` 指出是哪个 | 补上这个参数 |
| `400` | `invalid_parameter` | 参数格式或取值不对，`param` 指出是哪个 | 按接口文档的类型和范围改 |
| `400` | `unknown_parameter` | 传了接口不认识的参数（查询参数或请求体字段） | 删掉它，或检查拼写 |
| `400` | `invalid_json` | 请求体不是 JSON 对象 | 用 `Content-Type: application/json` 发送一个对象 |
| `413` | `too_long` | `text` 超过单次词数上限 | 按小节拆开，分几次调用 |
| `413` | `body_too_large` | 请求体太大：REST 最多 128 KB，MCP 最多 256 KB | 减少条数或缩短内容 |
| `429` | `rate_limit_exceeded` | 撞上了某一层限流，`message` 说明原因 | 等 `Retry-After` 秒再重试；多个进程共用一把密钥时把请求排队 |
| `429` `503` | `busy` | `429`：改写或核查排队的人太多。`503`：额度或用量暂时读写不了，没有处理也没有计量 | 有 `Retry-After` 就按它等，没有就退避后重试 |
| `502` | `upstream_unavailable` | 文献数据库、改写模型或核查服务没有响应 | 稍后重试，这次不计量 |

鉴权错误见[鉴权](https://paperpurr.com/docs/auth)，完整列表见[错误码](https://paperpurr.com/docs/errors)。

## 计量

- 内测期免费，计入请求频率限制。
- 核查的文本不保存。

下一页: [查文献](https://paperpurr.com/docs/search.md)
