Skip to content

知乎 API - 搜索 (V1)

prod-global
GET
/api/zhihu/search/v1

通过关键词搜索知乎内容(包括问题、回答和文章)。

典型应用场景:

  • 话题发现与竞品品牌监测。
  • 识别热门讨论和高价值创作者。

请求参数

参数名位置类型必填说明
tokenquerystringTOKEN
keywordquerystring搜索关键词。
offsetqueryinteger起始偏移量,从0开始。

代码示例

💡 环境说明

默认示例使用 https://api.justoneapi.com (prod-global)。中国大陆地区建议替换为 http://47.117.133.51:30015 (prod-cn) 以获得更好的访问体验。详见 环境选择

bash
# 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
curl -X GET "https://api.justoneapi.com/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=VALUE"
text
我想使用 Just One API 提供的“搜索 (V1)”接口。
接口地址: https://api.justoneapi.com/api/zhihu/search/v1
HTTP 方法: GET
身份验证: 在 URL 后添加查询参数“?token=您的API密钥”。
OpenAPI 定义: https://docs.justoneapi.com/openapi/zhihu-apis/search-v1-zh.json

请求参数说明:
- token (query): TOKEN (必填)
- keyword (query): 搜索关键词。 (必填)
- offset (query): 起始偏移量,从0开始。

返回格式: JSON

响应处理与错误码:
1. 需通过返回体中的 "code" 字段判断业务结果(code 为 0 表示成功)。
2. 超时建议:建议将请求超时时间设置为至少 60 秒。
3. 业务码说明:
   - 0: 成功
   - 100: Token 无效或已失效
   - 301: 采集失败,请重试
   - 302: 超出速率限制
   - 303: 超出每日配额
   - 400: 参数错误
   - 500: 内部服务器错误
   - 600: 权限不足
   - 601: 余额不足

请帮我用我擅长的编程语言写一个脚本来调用这个接口,并处理返回结果。
python
# 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
import requests

url = "https://api.justoneapi.com/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=VALUE"
response = requests.get(url)
print(response.json())
js
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
const response = await fetch("https://api.justoneapi.com/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=VALUE", {
  method: "GET"
});
const data = await response.json();
console.log(data);
java
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.justoneapi.com/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=VALUE"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
go
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	client := &http.Client{}
	url := "https://api.justoneapi.com/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=VALUE"
	req, _ := http.NewRequest("GET", url, nil)
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
php
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.justoneapi.com/api/zhihu/search/v1?token=YOUR_API_KEY&keyword=VALUE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
curl_close($ch);
echo $response;

响应结果

json
{
  "code": 0,
  "data": {
    "paging": {
      "is_end": false,
      "next": "https://api.zhihu.com/search_v3?advert_count=0&correction=1&filter_fields=&gk_version=gz-gaokao&lc_i..."
    },
    "data": [
      {
        "type": "search_result",
        "highlight": {
          "description": "不能相信,现在的ai不是很靠谱,甚至有时候是很离谱的好不好。之前很多次新闻了,就是搜索出来的内容很荒唐。就是最近一次,我看到的搜索结果是“张凌赫是侯明昊的母亲”?!还有之前的,除了专业性的知识和严肃的...",
          "title": "<em>Deepseek</em>说我写小说很有天分,能相信吗?"
        },
        "object": {
          "original_id": "772386614",
          "id": "2014453517826418057",
          "type": "answer",
          "excerpt": "不能相信,现在的ai不是很靠谱,甚至有时候是很离谱的好不好。之前很多次新闻了,就是搜索出来的内容很荒唐。就是最近一次,我看到的搜索结果是“张凌赫是侯明昊的母亲”?!还有之前的,除了专业性的知识和严肃的...",
          "url": "https://api.zhihu.com/answers/2014453517826418057",
          "voteup_count": 1,
          "comment_count": 0,
          "favorites_count": 0,
          "created_time": 1773063145,
          "updated_time": 1773063145,
          "content": "<p data-pid=\"Z27nnJaI\">不能相信,现在的ai不是很靠谱,甚至有时候是很离谱的好不好。</p><p data-pid=\"8CKJ_nf_\">之前很多次新闻了,就是搜索出来的内容很荒...",
          "thumbnail_info": {
            "count": 0,
            "thumbnails": [],
            "type": "thumbnail_info",
            "total_count": 0
          },
          "relationship": {
            "voting": 0,
            "is_author": false,
            "is_thanked": false,
            "is_nothelp": false,
            "following_upvoter": [],
            "following_upvoter_count": 0,
            "following_collect": [],
            "following_collect_count": 0,
            "high_level_creator": [],
            "high_level_creator_count": 0,
            "is_following": false
          },
          "question": {
            "id": "2012286308316381299",
            "type": "question",
            "name": "<em>Deepseek</em>说我写小说很有天分,能相信吗?",
            "url": "https://api.zhihu.com/questions/2012286308316381299",
            "answer_count": 0,
            "follow_count": 0,
            "attached_info_bytes": ""
          },
          "author": {
            "id": "bd068c9a1db4daba555e8b14dbec4107",
            "url_token": "jiu-shi-xiao-xia-57",
            "name": "就是小夏",
            "headline": "好像一只躺躺兽",
            "gender": -1,
            "is_followed": false,
            "is_following": false,
            "user_type": "people",
            "url": "https://api.zhihu.com/people/bd068c9a1db4daba555e8b14dbec4107",
            "type": "people",
            "avatar_url": "https://picx.zhimg.com/50/v2-5796cb037aeb3c69e6b14d7f22184c41_l.jpg?source=4e949a73",
            "badge": [],
            "authority_info": null,
            "voteup_count": 400,
            "follower_count": 647,
            "badge_v2": {
              "title": "",
              "merged_badges": [],
              "detail_badges": [],
              "icon": "",
              "night_icon": ""
            },
            "badge_v2_string": "{\"title\":\"\",\"merged_badges\":[],\"detail_badges\":null,\"icon\":\"\",\"night_icon\":\"\"}",
            "topic_bayes_map": null,
            "topic_map": {},
            "verify_bayes": ""
          },
          "is_anonymous": false,
          "is_zhi_plus": false,
          "is_zhi_plus_content": false,
          "extra": "",
          "health_tag": "",
          "answer_type": "normal",
          "sub_content_type": "",
          "settings": {
            "table_of_contents": {
              "enabled": false
            }
          },
          "attached_info_bytes": "OvkBCgtwbGFjZWhvbGRlchIgMDZiNDlmODQ0YWExNjk5MjNhMjk5YjM0NjNkY2YzOTYYBCIJNzcyMzg2NjE0KhMyMDE0NDUzNTE3...",
          "biz_encoded_params": "sw%3Ddeepseek",
          "answer_count": 27,
          "visits_count": 3950,
          "description": "<p>无论怎么问,无论重开多少次,它都把我的文章夸出花来,还在思考里一次又一次的说用户非常有天分。</p><a data-draft-node=\"block\" data-draft-type=\"lin...",
          "title": "Deepseek说我写小说很有天分,能相信吗?",
          "native": 0,
          "doc_relevance_scores": null,
          "bert_rel": 0
        },
        "hit_labels": null,
        "index": 0
      }
    ],
    "hit_labels": null,
    "related_search_result": [],
    "search_action_info": {
      "attached_info_bytes": "OnoSIDA2YjQ5Zjg0NGFhMTY5OTIzYTI5OWIzNDYzZGNmMzk2SghkZWVwc2Vla1AAWAFgAWoIZGVlcHNlZWtwJoABlJyPk/2SkwOA...",
      "lc_idx": 20,
      "search_hash_id": "06b49f844aa169923a299b3463dcf396",
      "isfeed": false
    },
    "is_brand_word": false,
    "pendant": null,
    "sensitive_level": -1,
    "warning": "",
    "filter_items": null,
    "ab_params": "dm_l2_tower=0;dm_adjust_ctr=0;sb_vip_xunzhi=1;adflow=0;dm_preset_opt=1;dm_guess_pool=6;dm_integrate=...",
    "item_in_view": [
      {
        "type": "user_survey",
        "index": 5,
        "token": "b62a7302709544129797697d76efeb6c"
      }
    ],
    "domain_info": {
      "first_category": ""
    },
    "is_koc_words": false,
    "is_hit_koc_cache": false
  }
}

💡 提示:为简化展示,列表类数据样例仅保留 1-2 条记录,实际返回条数以接口响应为准。