接口提供文字转拼音、拼音查汉字功能。
接口提供文字转拼音、拼音查汉字功能。
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| action | string | 是 | 接口类型:convert(使用默认值) | |
| text | string | 是 | 要转换的汉字文本 | 我爱音乐和数学 |
| mode | string | 否 | 转换模式: - with_tone: 带声调(默认) - no_tone: 不带声调 - first_letter: 首字母 - first_letter_upper: 首字母大写 | with_tone |
[
{
"name": "action",
"type": "string",
"required": true,
"description": "接口类型:convert(使用默认值)",
"example": ""
},
{
"name": "text",
"type": "string",
"required": true,
"description": "要转换的汉字文本",
"example": "我爱音乐和数学"
},
{
"name": "mode",
"type": "string",
"required": false,
"description": "转换模式: - with_tone: 带声调(默认) - no_tone: 不带声调 - first_letter: 首字母 - first_letter_upper: 首字母大写",
"example": "with_tone"
}
]{"openapi":"3.1.1","info":{"title":"文字拼音互转","description":"接口提供文字转拼音、拼音查汉字功能。","version":"1.0.0"},"paths":{"/apis/gateway?api=pinyin":{"get":{"summary":"文字拼音互转","description":"接口提供文字转拼音、拼音查汉字功能。","parameters":[{"name":"action","in":"query","required":true,"schema":{"type":"string"},"description":"接口类型:convert(使用默认值)"},{"name":"text","in":"query","required":true,"schema":{"type":"string","example":"我爱音乐和数学"},"description":"要转换的汉字文本"},{"name":"mode","in":"query","required":false,"schema":{"type":"string","example":"with_tone"},"description":"转换模式: - with_tone: 带声调(默认) - no_tone: 不带声调 - first_letter: 首字母 - first_letter_upper: 首字母大写"}],"responses":{"200":{"description":"成功","content":{"application/json":{"schema":{"type":"object"}}}}}},"post":{"summary":"文字拼音互转","description":"接口提供文字转拼音、拼音查汉字功能。","parameters":[{"name":"action","in":"query","required":true,"schema":{"type":"string"},"description":"接口类型:convert(使用默认值)"},{"name":"text","in":"query","required":true,"schema":{"type":"string","example":"我爱音乐和数学"},"description":"要转换的汉字文本"},{"name":"mode","in":"query","required":false,"schema":{"type":"string","example":"with_tone"},"description":"转换模式: - with_tone: 带声调(默认) - no_tone: 不带声调 - first_letter: 首字母 - first_letter_upper: 首字母大写"}],"responses":{"200":{"description":"成功","content":{"application/json":{"schema":{"type":"object"}}}}}}}},"servers":[{"url":"https://api.souxiaocha.com","description":"当前访问入口(https)"}]}
{"success":true,"code":200,"message":"success","data":{"original":"我爱音乐和数学","pinyin":"wǒ ài yīn yuè hé shù xué","mode":"with_tone","char_count":7},"execution_time":0.016,"timestamp":1788744812}https://api.souxiaocha.com/apis/gateway?api=pinyinGET https://api.souxiaocha.com/apis/gateway?api=pinyin apikey=你的API密钥&action=请填写action&text=我爱音乐和数学&mode=with_tone
GET 参数放在查询字符串中。参数值请替换为实际有效值。
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
action | string | 是 | 接口类型:convert(使用默认值) | |
text | string | 是 | 要转换的汉字文本 | 我爱音乐和数学 |
mode | string | 否 | 转换模式: - with_tone: 带声调(默认) - no_tone: 不带声调 - first_letter: 首字母 - first_letter_upper: 首字母大写 | with_tone |
{"success":true,"code":200,"message":"success","data":{"original":"我爱音乐和数学","pinyin":"wǒ ài yīn yuè hé shù xué","mode":"with_tone","char_count":7},"execution_time":0.016,"timestamp":1788744812}接口提供文字转拼音、拼音查汉字功能。
https://api.souxiaocha.com/apis/gateway?api=pinyin
GET / POST(业务参数 GET 通过 URL 传递,POST 支持表单或 JSON)
调用需携带平台密钥(用户中心「令牌管理」获取,SK- 开头):
key=SK-你的密钥X-API-Key: SK-你的密钥| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| action | string | 是 | 接口类型:convert(使用默认值) |
| text | string | 是 | 要转换的汉字文本 |
| mode | string | 否 | 转换模式: - with_tone: 带声调(默认) - no_tone: 不带声调 - first_letter: 首字母 - first_letter_upper: 首字母大写 |
[
{"name": "action", "type": "string", "required": true, "description": "接口类型:convert(使用默认值)"},
{"name": "text", "type": "string", "required": true, "description": "要转换的汉字文本"},
{"name": "mode", "type": "string", "required": false, "description": "转换模式: - with_tone: 带声调(默认) - no_tone: 不带声调 - first_letter: 首字母 - first_letter_upper: 首字母大写"}
]
成功返回示例:
{"success":true,"code":200,"message":"success","data":{"original":"我爱音乐和数学","pinyin":"wǒ ài yīn yuè hé shù xué","mode":"with_tone","char_count":7},"execution_time":0.016,"timestamp":1788744812}
失败返回示例:
{"success":false,"code":400,"message":"缺少text参数,请输入要转换的汉字","data":null,"execution_time":0.004,"timestamp":1788744832}
| 参数名 | 类型 | 说明 |
|---|---|---|
| success | boolean | 请求是否成功 |
| code | integer | 状态码:200成功,其他为错误 |
| message | string | 返回消息 |
| data | object | 返回数据 |
| data.original | string | 原始输入文本 |
| data.pinyin | string | 转换后的拼音 |
| data.mode | string | 使用的转换模式 |
| data.char_count | integer | 字符数量 |
| timestamp | integer | 时间戳 |
curl "https://api.souxiaocha.com/apis/gateway?api=pinyin?key=SK-你的密钥&action=convert&text=%E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C"
上游业务级错误:
| code | msg | 描述 |
|---|---|---|
| 400 | missing_action | 缺少action参数 |
| 400 | missing_text | 缺少text参数 |
| missing_pinyin | 缺少pinyin参数 |
平台级错误(errcode):11001 缺少密钥 / 11002 密钥无效或已禁用 / 11005 接口禁用 / 11006 接口维护 / 11010 积分不足 / 11018 请求方式不允许。
失败时请以响应体中的 code / errcode 与 msg 判断。
2026-09-24
curl "https://api.souxiaocha.com/apis/gateway?api=pinyin?key=SK-你的密钥&action=convert&text=%E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C"
// 结果将在此处显示