API 接口文档

快速集成题库搜索功能到您的应用

1

接口概述

接口地址

https://api2.gomooc.net/api.php

返回格式

JSON

请求方式

GET POST

请求示例

https://api2.gomooc.net/api.php
?token=xxx&question=问题&limit=5

请确保每项参数均不为空

2

参数说明

参数名 必填 类型 说明
token string 用户唯一token,在个人中心获取
question string 要搜索的问题关键词
limit int 返回的条数,不填默认为10
3

调用示例

JavaScript
const result = await fetch(
  "https://api2.gomooc.net/api.php?token=" + token +
  "&question=" + encodeURIComponent(question)
).then(r => r.json());

console.log(result.answer);
PHP
$token = "your_token_here";
$question = "问题";
$url = "https://api2.gomooc.net/api.php?" . http_build_query([
    "token" => $token,
    "question" => $question
]);

$response = file_get_contents($url);
$data = json_decode($response, true);
print_r($data);
Python
import requests

token = "your_token_here"
question = "问题"
url = "https://api2.gomooc.net/api.php"

params = {"token": token, "question": question}
response = requests.get(url, params=params)
data = response.json()
print(data)

准备好开始了吗?

立即注册账号,获取您的专属Token,开始集成强大的题库搜索功能

立即开始