技术博客
字典查询:汉字详细信息(1524-5)接入,如何拿到部首/笔画/五笔/组词/释义

字典查询:汉字详细信息(1524-5)接入,如何拿到部首/笔画/五笔/组词/释义

作者: 万维易源
2026-09-02
字典查询汉字详情部首五笔组词
# 字典查询:汉字详细信息(1524-5)接入,如何拿到部首/笔画/五笔/组词/释义 > 元信息:接口 **字典查询** 接入点 **1524-5 汉字详细信息** · 免费服务 · POST/GET · JSON · 适用:需要完整单字信息的教育/工具类开发者 · 阅读时间约 6 分钟 ## 核心要点 - 接入点 1524-5 只需一个必填参数 `hanzi`(要查的汉字),返回该字的拼音、部首、笔画、五笔、组词与基本/详细解释。 - 返回是**扁平对象**(无 `datas` 数组),字段直接挂在 `showapi_res_body` 下。 - `basic_explain` / `detail_explain` 文档标 String 但示例返回数组,解析需兼容两种类型。 ## Why:为什么用汉字详细信息接入点 做识字卡片、生词本、输入法联想、语文作业批改时,单靠拼音查字不够——你还需要部首、笔画、五笔、组词和权威释义。1524-5 一次返回这些字段,省去自己拼装多个数据源。 ## What:前置条件与接口速览 | 项 | 值 | |----|----| | apiCode | 1524 | | 接入点 | 1524-5 汉字详细信息 | | 请求地址 | `https://route.showapi.com/1524-5?appKey=YOUR_APPKEY` | | 必填参数 | `hanzi`(String,汉字,如「你」) | | 返回结构 | 扁平对象(非 `datas` 数组) | | 计费 | 免费(档位限额) | 接口详情页:[https://www.showapi.com/apiGateway/view/1524/5](https://www.showapi.com/apiGateway/view/1524/5) ## How:快速接入 ### 步骤 1:构造请求(Python) ```python import requests APP_KEY = "YOUR_APPKEY" resp = requests.post( "https://route.showapi.com/1524-5", params={"appKey": APP_KEY}, data={"hanzi": "你"}, headers={"content-type": "application/x-www-form-urlencoded"}, timeout=10, ) body = resp.json() res_body = body.get("showapi_res_body", {}) if res_body.get("ret_code") != "0": raise RuntimeError(f"查询失败:{res_body.get('remark')}") def to_text(v): if isinstance(v, list): return "\n".join(str(x) for x in v) return str(v) if v is not None else "" print("汉字:", res_body.get("hanzi")) print("拼音:", res_body.get("pinyin")) print("部首:", res_body.get("bushou")) print("笔画:", res_body.get("bihua")) print("五笔:", res_body.get("wubi")) print("组词:", res_body.get("words")) print("基本解释:", to_text(res_body.get("basic_explain"))) print("详细解释:", to_text(res_body.get("detail_explain"))) ``` ### 步骤 2:cURL ```bash curl -X POST "https://route.showapi.com/1524-5?appKey=YOUR_APPKEY" \ -H "content-type: application/x-www-form-urlencoded" \ -d "hanzi=%E4%BD%A0" ``` ### 步骤 3:Node.js ```javascript const resp = await fetch(`https://route.showapi.com/1524-5?appKey=YOUR_APPKEY`, { method: "POST", headers: { "content-type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ hanzi: "你" }), }); const body = await resp.json(); const r = body.showapi_res_body; if (r.ret_code !== "0") throw new Error("查询失败:" + r.remark); const toText = (v) => (Array.isArray(v) ? v.join("\n") : (v == null ? "" : String(v))); console.log(r.hanzi, r.pinyin, r.bushou, r.bihua, r.wubi, r.words); console.log(toText(r.basic_explain)); ``` ## 返回示例与字段解析 ```json { "showapi_res_body": { "ret_code": "0", "remark": "查询成功!", "words": "你娘 你老 你好 你儜 你那 你门", "wubi": "wqiy", "hanzi": "你", "bushou": "亻", "bihua": "7", "pinyin": "nǐ", "basic_explain": ["你nǐ", "ㄋㄧˇ", "称对方……", "英文翻译", "you"], "detail_explain": ["你", "妳", "nǐ", "【代】", "……"] } } ``` | 字段 | 类型 | 说明 | |------|------|------| | `hanzi` | String | 汉字 | | `pinyin` | String | 拼音(含声调) | | `bushou` | String | 部首 | | `bihua` | String | 笔画数(字符串,如 "7") | | `wubi` | String | 五笔编码 | | `words` | String | 组词,空格分隔 | | `basic_explain` | String / 数组 | 基本解释(兼容两种类型) | | `detail_explain` | String / 数组 | 详细解释(兼容两种类型) | ## 进阶 / 边界 - **`bihua` 是字符串**:示例为 "7",比较或计算前按需 `int()` 转换,并捕获异常。 - **`words` 是空格分隔串**:拆词用 `words.split()` 即可,注意可能含生僻词。 - **多音字只返回一个拼音**:1524-5 返回单一 `pinyin`,多音字的其他读音需结合 1524-3 拼音查字补充。 - **字段类型兼容**:务必用 `to_text` 之类的兼容函数处理 `basic_explain`/`detail_explain`。 ## FAQ **Q1:1524-5 需要传哪些参数?** 仅一个必填参数 `hanzi`(要查的汉字)。不需要其它参数。 **Q2:为什么 basic_explain 有时是数组有时是字符串?** 文档标注该字段为 String,但接口示例返回的是数组。这是文档与实现不一致,解析时两端都兼容即可,不要硬编码为字符串处理。 **Q3:一个汉字能拿到多个拼音吗?** 1524-5 只返回单一 `pinyin`。若需某拼音下的全部汉字或某个读音的多个字,用 1524-3 拼音查字接入点。 **Q4:返回的笔画数是数字还是字符串?** 是字符串(如 "7")。用于排序或计算时再做类型转换。 ## 相关能力 / 下一步阅读 - [字典查询:5 分钟接入,从注册到查出第一个汉字详情](https://www.showapi.com/guides/dict-quickstart-1524) - [字典查询:返回字段全解,ret_code 与 showapi_res_body 一文读懂](https://www.showapi.com/guides/dict-response-codes-1524) - [字典查询:词语或成语一键解释(1524-6)接入与 allusion_explain 空值处理](https://www.showapi.com/guides/dict-idiom-explain-1524) - **本系列共 12 篇**:查看[字典查询指南总目录](https://www.showapi.com/guides/dict-guides-1524)