首页 开发文档 脑筋急转弯

脑筋急转弯

随机返回脑筋急转弯。默认只返回题目用于出题,传 with_answer=1 才附带答案;difficulty 可按难度筛选,count 支持批量取题。

请求信息
请求地址 https://cx4.cn/openApi/content/riddle 复制
请求方式 GET / POST
接口标识 content_riddle
鉴权方式 必须
四种方式任选其一:Header「X-Api-Key」/ Header「Authorization: Bearer 你的key」/ URL 参数「?key=你的key」/ POST 参数「key」
请求参数
参数名 类型 必填 说明 示例
difficulty int 否 难度筛选:1 简单 / 2 中等 / 3 烧脑,0 不限 2
with_answer int 否 是否返回答案:1 返回 / 0 只给题目(默认) 1
count int 否 返回条数,1-20 3
返回参数

下表字段位于返回结构的 data 内;外层 code / message 为全平台统一格式,不在此重复列出。

参数名 类型 说明 示例
ok bool 是否成功 true
category string 固定值 brain_teaser brain_teaser
with_answer bool 本次是否附带答案,由入参 with_answer 决定 false
count int 实际返回条数 1
list array 题目对象数组,同一批次不重复 []
list[].id int 题目 ID 3161
list[].question string 题目文本 别用常理想:什么蛇不会爬?
list[].tags string 标签,逗号分隔 急转弯,逻辑,全年龄,d1
list[].difficulty int 难度:1 简单 / 2 中等 / 3 烧脑 1
list[].answer string 标准答案;仅 with_answer=1 时返回 蛇皮
list[].text string 「题目——答案」拼好的展示文本;仅 with_answer=1 时返回 别用常理想:什么蛇不会爬?——蛇皮
返回示例

成功

{
    "code": 200,
    "message": "操作成功",
    "data": {
        "ok": true,
        "category": "brain_teaser",
        "with_answer": false,
        "count": 1,
        "list": [
            {
                "id": 3161,
                "question": "别用常理想:什么蛇不会爬?",
                "tags": "急转弯,逻辑,全年龄,d1",
                "difficulty": 1
            }
        ]
    }
}

失败

{
    "code": 500,
    "message": "获取失败",
    "data": null
}
平台通用状态码
状态码 说明
200调用成功
400缺少必填参数或参数格式有误
401密钥缺失或无效
402余额不足,请充值后重试
403未开通该接口,请在本页开通后调用
404接口不存在或已下架
429触发限流,请稍后重试
500接口调用失败(已扣款的会自动退款)
调用示例

cURL 复制

curl -X POST "https://cx4.cn/openApi/content/riddle" -H "X-Api-Key: 你的SecretKey" -d "difficulty=2&with_answer=1&count=3"

JavaScript 复制

fetch('https://cx4.cn/openApi/content/riddle', {
  method: 'POST',
  headers: {
    'X-Api-Key': '你的SecretKey',
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: 'difficulty=2&with_answer=1&count=3'
})
.then(res => res.json())
.then(data => console.log(data));

PHP 复制

<?php
require 'vendor/autoload.php';

$client = new \GuzzleHttp\Client();
$response = $client->post('https://cx4.cn/openApi/content/riddle', [
    'headers' => ['X-Api-Key' => '你的SecretKey'],
    'form_params' => ['difficulty' => '2', 'with_answer' => '1', 'count' => '3'],
]);
echo $response->getBody();

Java 复制

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://cx4.cn/openApi/content/riddle"))
    .header("X-Api-Key", "你的SecretKey")
    .header("Content-Type", "application/x-www-form-urlencoded")
    .POST(HttpRequest.BodyPublishers.ofString("difficulty=2&with_answer=1&count=3"))
    .build();
HttpResponse<String> response = client.send(
        request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

Python 复制

import requests

res = requests.post('https://cx4.cn/openApi/content/riddle',
    headers={'X-Api-Key': '你的SecretKey'},
    data={'difficulty': '2', 'with_answer': '1', 'count': '3'})
print(res.json())
在线测试 (使用你的密钥真实调用,计费与正常调用一致)

登录后可在线测试: 立即登录

计费说明

免费


累计调用:10 次


快速上手

1. 注册并完成邮箱验证:立即注册

2. 登录后复制 Secret Key:去登录

3. 点击右侧「开通接口」按钮

4. 用下方「在线测试」一键体验,或复制下方示例代码直接调用