语法纠错 Grammar Check
AI 驱动的语法检查与自动纠错,覆盖 20+ 语言的拼写、语法、标点和用词错误。 AI-powered grammar checking and auto-correction for 20+ languages. Covers spelling, syntax, punctuation, and word choice.
快速概览 Quick Overview
语法纠错 API 采用深度学习模型,可精准识别并修正 20+ 种语言的拼写、语法、标点和风格问题。返回每个错误的详细位置、类型、原文和建议纠正方案,支持自动纠错和仅返回建议两种模式。适用于写作辅助、英语学习、内容审校、在线编辑器集成等场景。 The Grammar Check API uses deep learning to accurately identify and correct spelling, grammar, punctuation, and style issues across 20+ languages. Returns detailed position, type, original text, and suggested correction for each error. Supports auto-correction and suggestion-only modes. Ideal for writing assistance, English learning, content review, and online editor integration.
认证方式 Authentication
所有 API 请求需在 HTTP Header 中携带 Access Token 进行身份认证: All API requests must include an Access Token in the HTTP Header for authentication:
Authorization: Bearer YOUR_ACCESS_TOKEN
请前往 控制台 获取您的 Access Token。 Get your Access Token from the Dashboard .
请求头 Request Headers
Header Header 值 Value 必填 Required 说明 Description
Authorization Bearer {token}required Bearer 认证令牌 Bearer authentication token
Content-Type application/jsonrequired 请求体格式为 JSON Request body format is JSON
检查类型参考 Check Types Reference
类型 Type check_types 说明 Description 示例 Example
拼写 Spelling spelling检查单词拼写错误 Detect misspelled words recieve → receive recieve → receive
语法 Grammar grammar检查语法结构错误(主谓一致、时态等) Check grammar (agreement, tense, etc.) He go → He goes He go → He goes
标点 Punctuation punctuation检查标点符号使用是否正确 Check punctuation correctness 你好。你好吗 → 你好,你好吗 Let's eat Grandma → Let's eat, Grandma
风格 Style style检查措辞风格(冗余、被动语态、口语化等) Check style (redundancy, passive voice, informality) 进行了一个决定 → 决定 make a decision → decide
用词 Word Choice wordiness检查冗长表达,建议更简洁的替代 Detect wordy phrases, suggest concise alternatives 由于...的原因 → 因为 due to the fact that → because
请求端点 Endpoint
POST /v1/grammar
请求参数 Request Parameters
参数 Parameter 类型 Type 必填 Required 说明 Description
text string required 待检查文本,最大 50,000 字符 Text to check, max 50,000 characters
lang string optional 语言代码,如 en/zh/ja;不填则自动检测 Language code, e.g. en/zh/ja; auto-detect if omitted
auto_correct boolean optional 是否启用自动纠错,默认 false(仅返回建议) Enable auto-correction; default false (suggestions only)
check_types string[] optional 检查类型筛选,支持 spelling/grammar/punctuation/style/wordiness,默认全部 Filter check types; supports spelling/grammar/punctuation/style/wordiness; default all
severity string optional 最低严重级别:info/warning/error,默认 warning(仅返回 warning 及以上级别) Minimum severity: info/warning/error; default warning
disable_rules string[] optional 需要禁用的检查规则 ID 列表(如禁用牛津逗号检查) List of rule IDs to disable (e.g. disable Oxford comma check)
domain string optional 文本领域:general/academic/business/casual,默认 general Text domain: general/academic/business/casual; default general
请求示例 Request Examples
cURL
Python
JavaScript
Java
Go
curl -X POST https://api.itranslator.cc/v1/grammar \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "Their is many reasons to choose our servise.",
"lang": "en",
"auto_correct": true
}'
import requests
payload = {
"text": "Their is many reasons to choose our servise.",
"lang": "en",
"auto_correct": True
}
resp = requests.post(
"https://api.itranslator.cc/v1/grammar",
headers={"Authorization": f"Bearer {token}"},
json=payload
)
print(resp.json())
const payload = {
"text": "Their is many reasons to choose our servise.",
"lang": "en",
"auto_correct": true
};
const resp = await fetch("https://api.itranslator.cc/v1/grammar", {
method: "POST",
headers: { "Authorization": `Bearer ${token}`, "Content-Type": "application/json" },
body: JSON.stringify(payload)
});
console.log(await resp.json());
import com.google.gson.Gson;
import java.util.*;
OkHttpClient client = new OkHttpClient();
Map<String, Object> payload = new HashMap<>();
payload.put("text", "Their is many reasons to choose our servise.");
payload.put("lang", "en");
payload.put("auto_correct", true);
RequestBody body = RequestBody.create(
new Gson().toJson(payload),
MediaType.parse("application/json")
);
Request request = new Request.Builder()
.url("https://api.itranslator.cc/v1/grammar")
.header("Authorization", "Bearer " + token)
.post(body)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
payload := map[string]interface{}{
"text": "Their is many reasons to choose our servise.",
"lang": "en",
"auto_correct": true,
}
data, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.itranslator.cc/v1/grammar", bytes.NewBuffer(data))
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
响应字段 Response Fields
字段 Field 类型 Type 说明 Description
original string 原始文本 Original text
corrected string|null 纠正后的文本(auto_correct=true 时有值,否则为 null) Corrected text (set when auto_correct=true, else null)
issues object[] 发现的问题列表,按出现位置排序 List of issues found, sorted by position
issues_count integer 问题总数量 Total number of issues
lang string 检测到的语言代码 Detected language code
quality_score number 整体文本质量评分 0~100(100 为无错误) Overall quality score 0~100 (100 = no errors)
Issue 字段说明 Issue Object Fields
字段 Field 类型 Type 说明 Description
type string 问题类型:spelling/grammar/punctuation/style/wordiness Issue type: spelling/grammar/punctuation/style/wordiness
offset integer 错误在原文中的起始位置(0 起始字符索引) Start position in original text (0-based char index)
length integer 错误片段的字符长度 Character length of the error segment
wrong string 原文中的错误片段 Incorrect text segment from original
correct string 建议的正确替换 Suggested correct replacement
severity string 严重程度:info/warning/error Severity level: info/warning/error
message string 人类可读的错误说明 Human-readable error explanation
rule_id string 触发的检查规则 ID Triggered check rule ID
响应示例(自动纠错模式) Response Example (Auto-correct Mode)
{
"original": "Their is many reasons to choose our servise.",
"corrected": "There are many reasons to choose our service.",
"issues": [
{ "type": "grammar", "offset": 0, "length": 5, "wrong": "Their", "correct": "There",
"severity": "error", "rule_id": "CONFUSED_WORDS",
"message": "'Their' is a possessive pronoun. Use 'There' as the existential subject." },
{ "type": "grammar", "offset": 6, "length": 2, "wrong": "is", "correct": "are",
"severity": "error", "rule_id": "SUBJECT_VERB_AGREEMENT",
"message": "Subject-verb agreement: 'many reasons' requires plural 'are'." },
{ "type": "spelling", "offset": 43, "length": 7, "wrong": "servise", "correct": "service",
"severity": "error", "rule_id": "SPELLING",
"message": "Spelling error." }
],
"issues_count": 3,
"lang": "en",
"quality_score": 42
}
响应示例(仅建议模式) Response Example (Suggestion-only Mode)
{
"original": "我昨天去了图书馆,看了一本很有趣的书然后我去了咖啡馆。",
"corrected": null,
"issues": [
{ "type": "punctuation", "offset": 16, "length": 1, "wrong": ",", "correct": null,
"severity": "warning", "rule_id": "RUN_ON_SENTENCE",
"message": "建议在复合句中间添加逗号或分号分隔。" },
{ "type": "style", "offset": 12, "length": 4, "wrong": "看了", "correct": "阅读了",
"severity": "info", "rule_id": "INFORMAL_WORDING",
"message": "书面语中建议使用更正式的'阅读'替代'看'。" }
],
"issues_count": 2,
"lang": "zh",
"quality_score": 78
}
响应示例(无错误) Response Example (No Errors)
{
"original": "The quick brown fox jumps over the lazy dog.",
"corrected": null,
"issues": [],
"issues_count": 0,
"lang": "en",
"quality_score": 100
}
错误码 Error Codes
HTTP Code 错误码 Error Code 说明 Description
200 0成功 Success
400 1001参数错误,请检查必填参数和参数格式 Invalid parameter; check required fields and format
400 1002不支持的语言代码 Unsupported language code
400 1003不支持的 check_types 值,请参考检查类型参考表 Unsupported check_types value; see check types reference
400 1006disable_rules 中包含无效的规则 ID disable_rules contains invalid rule IDs
401 2001认证失败,Token 无效或已过期 Authentication failed; invalid or expired token
403 2003无权限访问该资源 Access denied; insufficient permissions
413 3001请求文本超出长度限制(最大 50,000 字符) Text exceeds maximum length (50,000 chars)
422 3002无法检测到有效文本内容(文本为空或仅含特殊字符) No valid text content detected (empty or special chars only)
429 4001请求频率超限,请稍后重试 Rate limit exceeded; please retry later
500 5001服务器内部错误,请重试或联系技术支持 Internal server error; retry or contact support
最佳实践 Best Practices
明确指定语言 :设置 lang 参数可提高检测准确率,自动检测在短文本场景下可能误判语种。
Specify language explicitly : Setting lang improves accuracy; auto-detect may misidentify short texts.
按需选择检查类型 :若仅需拼写检查,设置 check_types=["spelling"] 可减少无关建议并降低 token 消耗。
Filter check types as needed : Set check_types=["spelling"] for spelling-only check to reduce noise and token usage.
交互式编辑器用建议模式 :保持 auto_correct=false,让用户逐个确认修改,避免误改。
Use suggestion mode for interactive editors : Keep auto_correct=false to let users review each change.
匹配领域设置 :学术论文用 domain=academic,商业邮件用 domain=business,以获得更贴合语境的结果。
Match domain setting : Use domain=academic for papers, domain=business for emails to get context-aware results.
按位置高亮错误 :利用 offset 和 length 在前端实现文本选中高亮,提升用户体验。
Highlight errors by position : Use offset and length for text highlighting in the frontend for better UX.
禁用特定规则 :通过 disable_rules 关闭特定检查规则(如连续逗号偏好等),适应团队风格指南。
Disable specific rules : Use disable_rules to turn off certain checks (e.g. serial comma) to match team style guides.
使用场景 Use Cases
场景 Scenario 推荐参数 Recommended Params 说明 Notes
在线写作助手 Online Writing Assistant auto_correct=false, check_types=all实时检查用户输入,下划线标注错误并提供替换建议 Real-time check user input, underline errors and suggest replacements
英语学习工具 English Learning Tool auto_correct=false, lang=en, severity=error展示语法错误及详细解释,帮助学习者理解错误原因 Show grammar errors with detailed explanations to help learners
邮件自动校对 Email Auto-Proofread auto_correct=true, domain=business, severity=warning发送前自动纠正拼写和语法,确保商务邮件的专业性 Auto-correct before sending to ensure professional business emails
学术论文审校 Academic Paper Review auto_correct=false, domain=academic, check_types=["spelling","grammar","style"]全面检查论文中的拼写、语法和学术风格问题 Comprehensive check for spelling, grammar, and academic style issues
内容批处理 Batch Content Processing auto_correct=true, lang=auto批量处理 CMS 文章或多语言内容,自动修正后发布 Batch process CMS articles or multilingual content, auto-correct before publishing
无障碍辅助 Accessibility Assistance severity=info, check_types=["style","wordiness"]检查文本简洁性和可读性,帮助内容适配阅读障碍群体 Check conciseness and readability to make content accessible for dyslexic readers
使用说明
Notes
所有 API 请求均使用 HTTPS,建议开启 HTTP Keep-Alive 以提高性能。
All API requests use HTTPS; enable HTTP Keep-Alive for better performance.
请勿在客户端代码中暴露 Access Token,建议通过后端代理调用。
Do not expose your Access Token in client-side code; use a backend proxy.
推荐设置合理的超时时间(30 秒),并实现指数退避重试策略。
Set a reasonable timeout (30s) and implement exponential backoff for retries.
自动检测语言在文本少于 10 个字符时准确率可能下降,建议对此类短文本显式指定 lang。
Auto language detection accuracy may decrease for texts under 10 characters; specify lang explicitly for short texts.