Skip to content

Zhihu Keyword Search API (V1) ​

GET
API health status
Healthy Available Limited Mostly unavailable No data
Loading health status...

Search Zhihu by keyword with optional result-type, sort, time-interval, topic-display, and offset controls. Use it to find relevant answers, articles, or videos.

Parameters ​

NameInTypeRequiredDefaultDescription
tokenquerystringYes-TOKEN
keywordquerystringYes-Search keywords.
offsetqueryintegerNo0Start offset, begins with 0.
showAllTopicsquerystringNoFALSEWhether to show all topics.


Available Values:

- FALSE: Do not show topics.

- TRUE: Show all topics.
verticalquerystringNo-Result type filter.


Available Values:

- answer: Answers only.

- article: Articles only.

- zvideo: Videos only.
sortquerystringNo-Sorting criteria.


Available Values:

- upvoted_count: Most upvoted.

- created_time: Latest published.
timeIntervalquerystringNo-Publish time interval filter.


Available Values:

- a_day: Within one day.

- a_week: Within one week.

- a_month: Within one month.

- three_months: Within three months.

- half_a_year: Within half a year.

- a_year: Within one year.

Code Samples ​

bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=VALUE'
text
I want to use the "Keyword Search (V1)" API from JustOneAPI.
Base URL: https://api.justoneapi.com.
API Path: /api/zhihu/search/v1?token=YOUR_API_KEY&keyword=VALUE
API Endpoint: BASE_URL + /api/zhihu/search/v1?token=YOUR_API_KEY&keyword=VALUE
HTTP Method: GET
Authentication: Append the "token" query parameter to the URL.
OpenAPI Definition: https://docs.justoneapi.com/openapi/zhihu/keyword-search-v1-en.json

Parameters:
- token (query): TOKEN (Required)
- keyword (query): Search keywords. (Required)
- offset (query): Start offset, begins with 0.
- showAllTopics (query): Whether to show all topics.

Available Values:
- `FALSE`: Do not show topics.
- `TRUE`: Show all topics.
- vertical (query): Result type filter.

Available Values:
- `answer`: Answers only.
- `article`: Articles only.
- `zvideo`: Videos only.
- sort (query): Sorting criteria.

Available Values:
- `upvoted_count`: Most upvoted.
- `created_time`: Latest published.
- timeInterval (query): Publish time interval filter.

Available Values:
- `a_day`: Within one day.
- `a_week`: Within one week.
- `a_month`: Within one month.
- `three_months`: Within three months.
- `half_a_year`: Within half a year.
- `a_year`: Within one year.

Return format: safely handle JSON or text according to the actual Content-Type.

Response Handling & Error Codes:
1. Business results should be determined by the "code" field in the response body (code 0 means success).
2. Timeout Recommendation: Set the request timeout to 120 seconds. If 120 seconds is too long for your use case, use at least 60 seconds, but a small number of requests may time out before receiving a result.
3. Business Code Reference:
   - 0: Success
   - 100: Invalid or Inactive Token
   - 301: Collection Failed. Please Retry.
   - 302: Rate Limit Exceeded
   - 303: Daily Quota Exceeded
   - 400: Invalid Parameters
   - 500: Internal Server Error
   - 600: Permission Denied
   - 601: Insufficient Balance
   - 602: Token Budget Exceeded
4. Code 601 means the shared account balance is insufficient. Code 602 means the current API token's own cumulative budget limit has been reached. Token budget limits do not transfer funds out of the shared account balance.

Please help me write a script in my preferred programming language to call this API and handle the response.
python
import requests

BASE_URL = "https://api.justoneapi.com"  # Provided by OpenAPI servers

url = BASE_URL + "/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=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"; // Provided by OpenAPI servers
const url = BASE_URL + "/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=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"; // Provided by OpenAPI servers
        final String url = BASE_URL + "/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=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" // Provided by OpenAPI servers

func main() {
	client := &http.Client{Timeout: 120 * time.Second}
	url := BASE_URL + "/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=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'; // Provided by OpenAPI servers
$url = $BASE_URL . '/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=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;
}

Response Fields ​

Key fields in a successful response (code = 0).

Search results and pagination5 fields

data

Keyword search results and pagination when the successful payload is an object.

FieldTypeDescription
pagingobjectPagination state returned for this search response.
paging.is_endbooleanWhether this response reports the end of the search results. Stop when true, even if next is still present.
paging.nextstringPagination URL reported by Zhihu. When is_end is false, use its offset value in the next call to this endpoint and keep the keyword and filters unchanged.
dataarraySearch result cards returned at this offset. The array can be empty. Card types and available fields can vary.
related_search_resultarrayRelated search results supplied by Zhihu. The array can be empty.
Result cards8 fields

data.data[]

One search result card.

FieldTypeDescription
idinteger | stringIdentifier returned for the outer result card, when present.
typestringType of the outer search result card.
indexintegerResult index reported for this card.
highlightobject | nullHighlighted parts of the matching result, when supplied.
highlight.titlestringHighlighted title text supplied in the search card.
highlight.descriptionstringHighlighted description text supplied in the search card.
highlight.namestringHighlighted name supplied in the search card.
highlight.creatorstringHighlighted creator name supplied in the search card.
Content13 fields

data.data[].object

Content attached to the card, such as an answer, article, question, profile, or video. Fields depend on the content type.

FieldTypeDescription
idstringIdentifier supplied for the content attached to this card, when present.
typestringType of the content attached to the card.
titlestringTitle of the attached content, when supplied.
descriptionstring | objectDescription returned for the content. Some card types supply a structured description.
raw_descriptionstringRaw description string returned for the video content.
excerptstringText excerpt returned for the content. It can contain HTML.
contentstringBody returned for the content. It can contain HTML.
urlstringZhihu URL supplied for this content.
redirect_urlstringDestination URL supplied for the card, when present.
image_urlstringImage URL supplied for the card.
is_anonymousbooleanAnonymity flag reported for the content.
created_timeintegerCreation time reported for the content as Unix seconds.
updated_timeintegerLast update time reported for the content as Unix seconds.
Engagement7 fields

data.data[].object

FieldTypeDescription
voteup_countintegerUpvote count reported for the content or profile.
comment_countintegerComment count reported for the content.
favorites_countintegerFavorites count reported for the content.
visits_countintegerVisit count reported for the content.
answer_countintegerNumber of answers reported for the question or profile.
articles_countintegerNumber of articles reported for the profile.
follower_countintegerFollower count reported for the profile or question.
Related question5 fields

data.data[].object.question

Question associated with an answer result.

FieldTypeDescription
idstringZhihu question identifier.
namestringQuestion title returned with the answer.
typestringType of the associated question object.
urlstringURL returned for the associated question.
answer_countintegerAnswer count reported for the associated question.
Profile and author15 fields

data.data[].object

FieldTypeDescription
namestringDisplay name supplied for a profile result.
headlinestringProfile headline reported with a profile result.
avatar_urlstringProfile avatar URL.
url_tokenstringPublic profile slug used in Zhihu profile URLs.
authorobjectAuthor profile supplied with the content.
author.idstringAuthor profile identifier.
author.url_tokenstringPublic author slug used in Zhihu profile URLs.
author.namestringAuthor display name.
author.headlinestringAuthor profile headline.
author.avatar_urlstringAuthor profile avatar URL.
author.urlstringURL returned for the author profile.
author.typestringType of the author profile object.
author.follower_countintegerFollower count reported for the author.
author.voteup_countintegerUpvote count reported for the author.
creatorstringCreator name text supplied with the video result.
Video information17 fields

data.data[].object

FieldTypeDescription
zvideo_idstringIdentifier of the Zhihu video post.
video_idstringVideo media identifier.
video_urlstringVideo URL supplied for the result.
video_answer_urlstringURL supplied for the answer associated with the video, when present.
cover_urlstringVideo cover image URL.
created_atintegerCreation timestamp supplied for the video.
updated_atintegerLast update timestamp supplied for the video.
durationnumberDuration value reported for the video.
widthintegerVideo width in pixels.
heightintegerVideo height in pixels.
play_countintegerPlay count reported for the video.
video_infoobjectAdditional media information supplied with the video.
video_info.video_idstringVideo media identifier.
video_info.durationnumberDuration value reported in the video information.
video_info.widthintegerVideo width in pixels.
video_info.heightintegerVideo height in pixels.
video_info.play_countintegerPlay count reported in the video information.
Playback variants28 fields

data.data[].object.playlist

Playback variants grouped by their quality keys. Available variants can differ by video.

FieldTypeDescription
ldobjectLD playback variant, when returned.
ld.urlstringMedia URL returned for the playback variant.
ld.play_urlstringPlayback URL returned for the variant.
ld.widthintegerWidth of the playback variant in pixels.
ld.heightintegerHeight of the playback variant in pixels.
ld.formatstringMedia format reported for the playback variant.
ld.qualitystringQuality label reported for the playback variant.
sdobjectSD playback variant, when returned.
sd.urlstringMedia URL returned for the playback variant.
sd.play_urlstringPlayback URL returned for the variant.
sd.widthintegerWidth of the playback variant in pixels.
sd.heightintegerHeight of the playback variant in pixels.
sd.formatstringMedia format reported for the playback variant.
sd.qualitystringQuality label reported for the playback variant.
hdobjectHD playback variant, when returned.
hd.urlstringMedia URL returned for the playback variant.
hd.play_urlstringPlayback URL returned for the variant.
hd.widthintegerWidth of the playback variant in pixels.
hd.heightintegerHeight of the playback variant in pixels.
hd.formatstringMedia format reported for the playback variant.
hd.qualitystringQuality label reported for the playback variant.
fhdobjectFHD playback variant, when returned.
fhd.urlstringMedia URL returned for the playback variant.
fhd.play_urlstringPlayback URL returned for the variant.
fhd.widthintegerWidth of the playback variant in pixels.
fhd.heightintegerHeight of the playback variant in pixels.
fhd.formatstringMedia format reported for the playback variant.
fhd.qualitystringQuality label reported for the playback variant.

Response Example ​

Loading the response example...