一言

GET
https://api.xuewutheme.com/api/yiyan

总有一句话,能穿越人海,触动你。

接口概述

动漫也好、小说也好、网络也好,不论在哪里,我们总会看到有那么一两个句子能穿透你的心。

请求参数

参数名 类型 必填 描述
apikey string 整数 string

用户开通的apikey

type string 整数 string

type参数支持b漫画、c游戏、d文学、e原创、f来自网络、g其他、h影视、i诗词、j网易云、k哲学,或all全部随机,不传则随机类别,例如?type=c获取游戏类一言。

charset string 整数 string

设置字符编码,如:utf-8、gbk

format string 整数 string

控制返回格式 text文本、json

响应参数

成功响应

状态码: 200 OK
格式: json
参数名 类型 描述
msg string string

返回的内容

响应示例

JSON
{
  "code": 200,
  "msg": "倘若只是为了驱赶心中的寂寞,找谁都可以的。",
  "tips": "雪舞api"
}

请求示例

cURL

Bash
curl -X GET \
  "https://api.example.com/v1/users/12345" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json"

Python

Python
import requests

url = "https://api.example.com/v1/users/12345"
headers = {
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
print(response.json())

JavaScript

JavaScript
const response = await fetch(
  'https://api.example.com/v1/users/12345',
  {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
      'Content-Type': 'application/json'
    }
  }
);

const data = await response.json();
console.log(data);

PHP

PHP
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.example.com/v1/users/12345");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

$headers = array();
$headers[] = "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

curl_close($ch);

错误码

状态码 描述
100 您的apikey值为空!
101 您的apikey值不存在!
103 当前接口为实名认证后可用,请您先进行实名!
104 请求频率超限!
105 接口不存在或已下线!
106 您的余额不足,请及时充值!
107 您当前的接口免费使用次数已用完,请明日再来!
109 您的账号已被封禁,不可使用任何接口!

错误响应示例

JSON
{
  "code": 1001,
  "message": "用户不存在",
  "data": null
}