绕口令与谜语查询:绕口令关键词检索实战(按"扁担""八百标兵"精准查找)
# 绕口令与谜语查询:绕口令关键词检索实战(按"扁担""八百标兵"精准查找)
**接口**:绕口令与谜语查询(apiCode=1623)· 接入点 1623-1 绕口令|**是否免费**:免费(含使用档次限制)|**请求方式**:POST/GET|**返回格式**:JSON|**适用人群**:全栈、小程序开发者、内容运营|**阅读时间**:约 5 分钟
## 核心要点
- 绕口令接入点用 `title` 参数做关键词检索(可选,留空返回默认列表)。
- 配合 `page` 做分页;单页返回约 10 条,`allPages` 告诉你可以翻多少页。
- 客户端超时建议 5s(对齐官方 `x-read-timeout`)。
## Why:用关键词把「语料」变成「素材」
做口才打卡、普通话练习、亲子互动时,你往往需要「某一类」绕口令(比如含「b/p」爆破音的「八百标兵」)而不是随机一条。用 `title` 关键词就能精准取料,避免自己爬网页、手录语料。
## What:接口速览
| 项目 | 说明 |
|------|------|
| 接口地址 | `https://route.showapi.com/1623-1?appKey={your_appKey}` |
| 检索参数 | `title`(String,否,绕口令关键词,如「扁担」「八百标兵」) |
| 分页参数 | `page`(String,否,默认 1) |
| 返回内容 | `contentlist[]` 每项含 `title`(标题)+ `content`(内容) |
| 超时 | 5s |
## How:带关键词调用
**Python(requests)**
```python
import requests
APP_KEY = "YOUR_APPKEY"
URL = "https://route.showapi.com/1623-1"
def query_twisters(keyword: str, page: int = 1):
resp = requests.post(
URL,
params={"appKey": APP_KEY},
data={"title": keyword, "page": str(page)},
timeout=5,
)
data = resp.json()
body = data["showapi_res_body"]
if body["ret_code"] != "0":
raise RuntimeError(data.get("showapi_res_error"))
return body
body = query_twisters("扁担", page=1)
print("总数:", body["allNum"], "总页:", body["allPages"])
for item in body["contentlist"]:
print(f"【{item['title']}】{item['content']}")
```
**cURL**
```bash
curl -X POST "https://route.showapi.com/1623-1?appKey=YOUR_APPKEY" \
-H "content-type: application/x-www-form-urlencoded" \
-d "title=%E6%89%81%E6%8B%85&page=1"
```
**Node.js(fetch)**
```javascript
const APP_KEY = "YOUR_APPKEY";
async function queryTwisters(keyword, page = 1) {
const url = `https://route.showapi.com/1623-1?appKey=${APP_KEY}`;
const body = new URLSearchParams({ title: keyword, page: String(page) });
const resp = await fetch(url, {
method: "POST",
headers: { "content-type": "application/x-www-form-urlencoded" },
body,
signal: AbortSignal.timeout(5000),
});
const data = await resp.json();
const resBody = data.showapi_res_body;
if (resBody.ret_code !== "0") throw new Error(data.showapi_res_error);
return resBody;
}
const body = await queryTwisters("扁担", 1);
console.log("总数:", body.allNum, "总页:", body.allPages);
for (const it of body.contentlist) console.log(`【${it.title}】${it.content}`);
```
## 返回示例与解析
```json
{
"showapi_res_body": {
"ret_code": "0",
"contentlist": [
{ "title": "板凳与扁担", "content": "板凳宽,扁担长。扁担没有板凳宽,板凳没有扁担长。" }
],
"maxResult": "1000",
"allNum": "10",
"allPages": "100",
"currentPage": "1"
}
}
```
字段含义见[返回字段与 ret_code 全解](https://www.showapi.com/guides/tongue-riddle-response-fields-1623)。
## 进阶 / 边界
- 想一次拿多页:用 `page` 从 1 循环到 `allPages`,见[分页遍历指南](https://www.showapi.com/guides/tongue-riddle-pagination-1623)。
- 免费接口有档次限制,循环前建议加本地缓存,见[免费档位下的调用纪律](https://www.showapi.com/guides/tongue-riddle-cache-tier-1623)。
- 关键词无匹配时 `contentlist` 为空数组但 `ret_code` 可能仍为 `"0"`,用「数组长度 + ret_code」双重判断。
## FAQ
**Q1:title 必填吗?**
A:否,可选。不传或留空会返回默认列表,适合做「随机一条」。
**Q2:关键词支持模糊匹配吗?**
A:以接口实际匹配行为为准;示例中「扁担」能命中标题含「扁担」的条目,建议传具体词验证。
**Q3:一次能返回多少条?**
A:单页约 10 条,`maxResult` 上限 1000;多页用 `page` 翻。
**Q4:超时设多少?**
A:绕口令接入点官方超时 5s,客户端对齐即可。
**Q5:返回的是数组还是对象?**
A:`contentlist` 是数组,空结果为空数组 `[]`,不要按 `null` 处理。
## 下一步阅读
- [绕口令与谜语查询:谜语关键词检索实战](https://www.showapi.com/guides/tongue-riddle-riddle-query-1623)
- [绕口令与谜语查询:分页遍历指南](https://www.showapi.com/guides/tongue-riddle-pagination-1623)
- [绕口令与谜语查询:返回字段与 ret_code 全解](https://www.showapi.com/guides/tongue-riddle-response-fields-1623)
- **本系列共 12 篇**:查看[绕口令与谜语查询指南总目录](https://www.showapi.com/guides/tongue-riddle-guides-1623)