Skip to content

知乎回答列表 API (V1) ​

GET
接口健康状态
健康 可用 少量可用 基本不可用 暂无数据
正在加载健康状态…

获取知乎问题的回答,具有排序和分页控制功能。用于浏览已知问题的回答,并继续查看更多的回答页面。

请求参数 ​

参数名位置类型必填默认值说明
tokenquerystring是-TOKEN
questionIdquerystring是-问题 ID
cursorquerystring否上一结果的翻页游标。
offsetqueryinteger否0起始偏移量,从0开始。
orderquerystring否_updated答案的排序标准。


可用值:

- _default:默认排序。

- _updated:按更新时间排序。
sessionIdquerystring否先前结果中的会话 ID。

代码示例 ​

bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/zhihu/get-answer-list/v1?token=YOUR_API_KEY&questionId=VALUE'
text
我想使用 JustOneAPI 提供的“回答列表 (V1)”接口。
接入地址: https://api.justoneapi.com。
接口路径: /api/zhihu/get-answer-list/v1?token=YOUR_API_KEY&questionId=VALUE
接口地址: BASE_URL + /api/zhihu/get-answer-list/v1?token=YOUR_API_KEY&questionId=VALUE
HTTP 方法: GET
身份验证: 在 URL 中传入 token 查询参数。
OpenAPI 定义: https://docs.justoneapi.com/openapi/zhihu/answer-list-v1-zh.json

请求参数说明:
- token (query): TOKEN (必填)
- questionId (query): 问题 ID (必填)
- cursor (query): 上一结果的翻页游标。
- offset (query): 起始偏移量,从0开始。
- order (query): 答案的排序标准。

可用值:
- `_default`:默认排序。
- `_updated`:按更新时间排序。
- sessionId (query): 先前结果中的会话 ID。

返回格式: 请根据实际 Content-Type 安全处理 JSON 或文本响应。

响应处理与错误码:
1. 需通过返回体中的 "code" 字段判断业务结果(code 为 0 表示成功)。
2. 超时建议:建议将请求超时时间设置为 120 秒;如果 120 秒偏长,请至少设置为 60 秒,但可能会有少量请求因超时而未接收到结果。
3. 业务码说明:
   - 0: 成功
   - 100: Token 无效或已失效
   - 301: 采集失败,请重试
   - 302: 超出速率限制
   - 303: 超出每日配额
   - 400: 参数错误
   - 500: 内部服务器错误
   - 600: 权限不足
   - 601: 账户余额不足
   - 602: TOKEN 限额超限
4. code 601 表示账户共享余额不足。code 602 表示当前 API TOKEN 自身的累计消费上限已达到。TOKEN 限额不是资金划拨,多个 TOKEN 仍共享同一个账户余额。

请帮我用我擅长的编程语言写一个脚本来调用这个接口,并处理返回结果。
python
import requests

BASE_URL = "https://api.justoneapi.com"  # 由 OpenAPI servers 提供

url = BASE_URL + "/api/zhihu/get-answer-list/v1?token=YOUR_API_KEY&questionId=VALUE"
response = requests.get(url, timeout=120)
print(response.status_code)
if response.content:
    content_type = response.headers.get("content-type", "").lower()
    if "json" in content_type:
        try:
            print(response.json())
        except ValueError:
            print(response.text)
    elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
        print(response.text)
    else:
        with open("response.bin", "wb") as output:
            output.write(response.content)
        print(f"Saved {len(response.content)} bytes to response.bin")
js
const BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
const url = BASE_URL + "/api/zhihu/get-answer-list/v1?token=YOUR_API_KEY&questionId=VALUE";

const response = await fetch(url, {
  method: "GET",
  signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
  const contentType = (response.headers.get("content-type") || "").toLowerCase();
  const mediaType = contentType.split(";", 1)[0].trim();
  const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
  if (textual) {
    const responseText = new TextDecoder().decode(responseBytes);
    let data = responseText;
    if (contentType.includes("json")) {
      try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
    }
    console.log(data);
  } else {
    console.log(`Received ${responseBytes.byteLength} binary bytes`);
  }
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    public static void main(String[] args) throws Exception {
        final String BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
        final String url = BASE_URL + "/api/zhihu/get-answer-list/v1?token=YOUR_API_KEY&questionId=VALUE";

        HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
        HttpRequest.Builder builder = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .timeout(Duration.ofSeconds(120))
            .method("GET", HttpRequest.BodyPublishers.noBody());

        HttpRequest request = builder.build();

        HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
        System.out.println(response.statusCode());
        String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
        String mediaType = contentType.split(";", 2)[0].trim();
        if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
            System.out.println(new String(response.body(), StandardCharsets.UTF_8));
        } else {
            Files.write(Path.of("response.bin"), response.body());
            System.out.println("Saved " + response.body().length + " bytes to response.bin");
        }
    }
}
go
package main

import (
	"fmt"
	"io"
	"os"
	"strings"
	"net/http"
	"time"
)

const BASE_URL = "https://api.justoneapi.com" // 由 OpenAPI servers 提供

func main() {
	client := &http.Client{Timeout: 120 * time.Second}
	url := BASE_URL + "/api/zhihu/get-answer-list/v1?token=YOUR_API_KEY&questionId=VALUE"
	req, _ := http.NewRequest("GET", url, nil)
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	fmt.Println(resp.StatusCode)
	bodyBytes, _ := io.ReadAll(resp.Body)
	contentType := strings.ToLower(resp.Header.Get("Content-Type"))
	mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
	if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
		fmt.Println(string(bodyBytes))
	} else {
		os.WriteFile("response.bin", bodyBytes, 0600)
		fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
	}
}
php
<?php
$BASE_URL = 'https://api.justoneapi.com'; // 由 OpenAPI servers 提供
$url = $BASE_URL . '/api/zhihu/get-answer-list/v1?token=YOUR_API_KEY&questionId=VALUE';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
    echo $response;
} else {
    file_put_contents('response.bin', $response);
    echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}

返回字段 ​

业务成功时(code = 0)的主要返回字段。

回答列表与分页5 个字段

data

知乎问题的回答卡片及分页信息。

字段类型说明
dataarray当前页返回的回答卡片。
pagingobject回答列表的分页信息。
paging.pageinteger知乎返回的当前页码。
paging.is_endboolean知乎是否将此页标记为回答列表末页。
paging.nextstring下一页地址。is_end 为 false 时,从此地址读取 cursor 和 offset,并将其中的 session_id 映射到请求参数 sessionId。使用相同的 questionId 和 order 发起续页请求。
回答卡片3 个字段

data.data[]

当前问题返回的一张回答卡片。

字段类型说明
typestring知乎返回的卡片类型。
target_typestring卡片承载的内容类型。
positioninteger知乎返回的回答卡片位置。
回答内容12 个字段

data.data[].target

卡片中的回答。

字段类型说明
idstring知乎回答 ID。
typestring当前回答记录的内容类型。
answer_typestring知乎返回的回答子类型。
business_typestring知乎返回的附加回答类别代码。
contentstring以 HTML 返回的回答正文。
excerptstring回答的纯文本摘要。
created_timeinteger回答创建时间,Unix 时间戳,单位为秒。
updated_timeinteger回答更新时间,Unix 时间戳,单位为秒。
urlstring知乎返回的回答地址。
content_need_truncatedboolean知乎是否标记回答需要截断显示。
ip_infostring知乎为回答展示的属地标签,可能省略。
is_stickyboolean知乎是否将此回答标记为置顶。
评论与展示状态7 个字段

data.data[].target

字段类型说明
is_collapsedboolean知乎是否将此回答标记为折叠。
collapse_reasonstring回答被折叠的原因文案,若有提供。
admin_closed_commentboolean知乎是否标记此回答的评论已由管理方关闭。
comment_permissionstring知乎返回的回答评论权限代码。
can_commentobject回答的评论可用状态。
can_comment.statusboolean此响应是否显示该回答可评论。
can_comment.reasonstring随评论可用状态返回的原因,若有提供。
互动数据9 个字段

data.data[].target

字段类型说明
voteup_countinteger回答的赞同数。
comment_countinteger回答的评论数。
thanks_countinteger回答收到的感谢数。
favlists_countinteger与回答关联的收藏夹数量。
reactionobject回答的互动信息。
reaction.statisticsobject知乎的互动统计计数。
reaction.statistics.like_countinteger互动统计中的点赞数,可能与 voteup_count 不同。
reaction.statistics.down_vote_countinteger互动统计中的反对数。
reaction.statistics.favoritesinteger互动统计中的收藏数。
问题资料7 个字段

data.data[].target.question

回答所属的知乎问题。

字段类型说明
idstring知乎问题 ID。
titlestring问题标题。
typestring问题记录的内容类型。
question_typestring知乎返回的问题子类型。
urlstring知乎返回的问题地址。
createdinteger问题创建时间,Unix 时间戳,单位为秒。
updated_timeinteger问题更新时间,Unix 时间戳,单位为秒。
缩略图8 个字段

data.data[].target.thumbnail_info

随回答返回的缩略图信息。

字段类型说明
typestring回答缩略图的分组类型。
countinteger与回答关联的缩略图数量。
thumbnailsarray随回答提供的缩略图条目。
thumbnails[]object一张回答缩略图。
thumbnails[].typestring此缩略图对应的媒体类型。
thumbnails[].urlstring缩略图地址。
thumbnails[].widthinteger缩略图宽度,单位为像素。
thumbnails[].heightinteger缩略图高度,单位为像素。
作者资料10 个字段

data.data[].target.author

回答作者公开展示的资料。

字段类型说明
idstring回答作者的知乎 ID。
namestring回答作者的显示名称。
headlinestring回答作者公开展示的个人简介。
urlstring返回的回答作者资料地址。
avatar_urlstring回答作者的头像地址。
avatar_url_templatestring回答作者返回的头像地址模板。
typestring回答作者的账号类型。
user_typestring知乎返回的附加作者类型代码。
follower_countinteger回答作者的粉丝数。
is_orgboolean知乎是否将作者标记为机构账号。
作者徽章与勋章16 个字段

data.data[].target.author

字段类型说明
badgearray随回答作者展示的徽章。
badge[]object一个作者展示标记。
badge[].typestring知乎返回的徽章类型。
badge[].descriptionstring徽章公开展示的说明。
exposed_medalobject作者资料展示的勋章信息。
exposed_medal.medal_idstring已展示的勋章 ID。
exposed_medal.medal_namestring勋章的显示名称。
exposed_medal.descriptionstring勋章展示的说明。
exposed_medal.avatar_urlstring随作者头像展示的勋章图片地址。
exposed_medal.mini_avatar_urlstring小尺寸勋章图片地址,若有提供。
exposed_medal.medal_avatar_framestring已展示勋章的头像框信息。
vip_infoobject作者公开展示的大会员标识信息。
vip_info.is_vipboolean当前展示的作者资料是否标记为会员。
vip_info.vip_iconobject会员图标地址,若有提供。
vip_info.vip_icon.urlstring默认会员图标地址。
vip_info.vip_icon.night_mode_urlstring深色模式的会员图标地址。
赞赏与认可10 个字段

data.data[].target

字段类型说明
reward_infoobject回答展示的赞赏信息。
reward_info.is_rewardableboolean知乎是否标记此回答可接受赞赏。
reward_info.reward_member_countinteger赞赏过回答的账号数量。
reward_info.taglinestring赞赏区域的显示文案,若有提供。
endorsementsarray随回答展示的认可信息,若有提供。
endorsements[]object一项已展示的认可信息。
endorsements[].elementsarray认可条目中展示的元素。
endorsements[].elements[]object一个已展示的认可元素。
endorsements[].elements[].typestring认可条目中元素的显示类型。
endorsements[].elements[].contentstring此元素展示的公开文字,若有提供。

响应示例 ​

正在加载响应示例…