错别字检查 API 接口文档

最新版本: 2025-03-19
GitHub 文档

API 概述

秉持着开放、共享、服务的理念,我们提供了中文错别字检查的 API 接口,支持多种编程语言调用。

如果遇到任何问题,请通过网站首页提供的联系方式咨询,我们将竭诚为您服务。

API 使用说明

HTTP 接口规范

请求地址 http://www.cuobiezi.net/api/v1/zh_spellcheck/json
请求方式 POST
Content-Type application/x-www-form-urlencoded

请求参数

编号 参数名 参数类型 含义 备注
1 content 字符串 检查错别字的正文 必填
2 check_mode 字符串 检查模式 固定值: advanced
3 action 字符串 操作类型 固定值: show
4 doc_type 字符串 文章内容类型
查看可选值
  • common - 通用类型
  • personal - 个人体会感想
  • company - 企业工作文档
  • introduction - 说明书
  • gov - 政府公文
  • law - 合同、法律文书
  • media - 媒体
5 company_name 字符串 公司名称 选填

代码示例

import requests

# 错别字检查请求
response = requests.post(
    "http://www.cuobiezi.net/api/v1/zh_spellcheck/json", 
    data={
        'content': '我最喜欢的就是元霄节吃汤圆。', 
        'check_mode': 'advanced',
        'action': 'show',
        'doc_type': 'common'
    }
)

# 打印响应结果
print(response.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        using (var httpClient = new HttpClient())
        {
            var values = new Dictionary
            {
                { "content", "我最喜欢的就是元霄节吃汤圆。" },
                { "check_mode", "advanced" },
                { "action", "show" },
                { "doc_type", "common" }
            };

            var content = new FormUrlEncodedContent(values);
            var response = await httpClient.PostAsync(
                "http://www.cuobiezi.net/api/v1/zh_spellcheck/json", 
                content
            );

            var responseString = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseString);
        }
    }
}
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class CuoBieZiExample {
    public static void main(String[] args) throws IOException {
        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
            HttpPost post = new HttpPost("http://www.cuobiezi.net/api/v1/zh_spellcheck/json");
            
            List params = new ArrayList<>();
            params.add(new BasicNameValuePair("content", "我最喜欢的就是元霄节吃汤圆。"));
            params.add(new BasicNameValuePair("check_mode", "advanced"));
            params.add(new BasicNameValuePair("action", "show"));
            params.add(new BasicNameValuePair("doc_type", "common"));
            
            post.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
            
            try (CloseableHttpResponse response = httpClient.execute(post)) {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    String result = EntityUtils.toString(entity);
                    System.out.println(result);
                }
            }
        }
    }
}
<?php
$url = 'http://www.cuobiezi.net/api/v1/zh_spellcheck/json';
$data = array(
    'content' => '我最喜欢的就是元霄节吃汤圆。',
    'check_mode' => 'advanced',
    'action' => 'show',
    'doc_type' => 'common'
);

$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

echo $result;
?>

响应示例

{
  "success": true,
  "text": "我最喜欢的就是元霄节吃汤圆。",
  "errors": [
    {
      "error_type": "别字",
      "position": 7,
      "error_word": "元霄",
      "correct_word": "元宵",
      "message": "'元霄'应改为'元宵'"
    }
  ]
}

集成示例

我们提供了多种集成方式,方便您在不同场景下使用错别字检查服务:

在线体验

立即试用我们的错别字检查服务

立即体验