zhihu-developer

Zhihu Open Data Platform API skill: for calling and processing the Zhihu Open Data Platform APIs, suitable for automated scenarios and scripts that need to obtain and use Zhihu data via API.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "zhihu-developer" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-e0b541c47d58389da9d8639df00ef6b19d3919822769a26e1fb1987372ac2287. Verify the upstream source and version against https://skillhub.cn/skills/user_b22a52ba/zhihu-developer before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Zhihu Open Data Platform API skill: for calling and processing the Zhihu Open Data Platform APIs, suitable for automated scenarios and scripts that need to obtain and use Zhihu data via API.

0 Downloads

Introduction source: third_party · user_b22a52ba · 2.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: zhihu-developer
description: 知乎数据开放平台 API 调用技能。通过知乎官方开放平台的 Access Secret 调用搜索、直答、热榜等接口。支持:(1) 知乎站内搜索——搜索知乎问题、回答、文章;(2)
  全网搜索——支持按站点域名、发布时间等条件过滤的全网内容搜索;(3) 知乎直答——调用知乎直答 AI 模型(快速回答/深度思考/智能思考)进行对话问答;(4)
  知乎热榜——获取当前知乎热榜内容列表。所有接口采用 Bearer 鉴权(Authorization + X-Request-Timestamp)。触发关键词:知乎搜索、知乎API、知乎开放平台、知乎直答、知乎热榜、全网搜索、zhihu
  search、zhihu hot list、zhida、知乎数据。
version: 2.0.0
tags:
- zhihu
slug: zhihu-developer
displayName: Zhihu Developer
summary: 知乎数据开放平台 API 调用技能

知乎数据开放平台 API 技能

通过知乎官方开放平台(developer.zhihu.com)提供的 REST API,实现知乎搜索、全网搜索、知乎直答 AI 对话、知乎热榜获取等功能。

API 端点

功能 方法 URL
知乎搜索 GET https://developer.zhihu.com/api/v1/content/zhihu_search
全网搜索 GET https://developer.zhihu.com/api/v1/content/global_search
知乎直答 POST https://developer.zhihu.com/v1/chat/completions
知乎热榜 GET https://developer.zhihu.com/api/v1/content/hot_list

鉴权方式

所有接口统一使用 Bearer 鉴权,需在请求头中携带:

Authorization: Bearer <your_access_secret>
X-Request-Timestamp: <unix_seconds>
Content-Type: application/json
  • Authorization:Bearer Token,填入 Access Secret
  • X-Request-Timestamp:秒级 Unix 时间戳
  • Content-Type:固定值 application/json

Access Secret 获取

在知乎开放平台个人中心(https://developer.zhihu.com/profile)查看并获取 Access Secret。

接口详情

1. 知乎搜索

站内内容搜索,返回知乎上的问题、回答、文章。

请求参数(Query):

参数 类型 必填 说明
Query String 是 搜索关键词
Count Int32 否 返回数量,默认 10,最大 10

Python 调用示例:

import requests, time

API_KEY = "<your_access_secret>"

def zhihu_search(query: str, count: int = 5):
    """知乎站内搜索"""
    url = "https://developer.zhihu.com/api/v1/content/zhihu_search"
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "X-Request-Timestamp": str(int(time.time())),
        "Content-Type": "application/json",
    }
    params = {"Query": query, "Count": min(count, 10)}
    r = requests.get(url, params=params, headers=headers, timeout=15)
    r.raise_for_status()
    data = r.json()
    if data.get("Code") != 0:
        raise Exception(f"API Error: {data.get('Message')}")
    return data["Data"]

响应字段(Item):

字段 说明
Title 内容标题
ContentType 内容类型(Answer/Article/Question)
ContentID 内容标识
ContentText 内容摘要
Url 内容链接
CommentCount 评论数
VoteUpCount 赞同数
AuthorName 作者昵称
AuthorAvatar 作者头像 URL
AuthorBadgeText 认证文案
EditTime 发布/更新时间戳
AuthorityLevel 权威等级(1-4)
CommentInfoList 精选评论

2. 全网搜索

全网内容搜索,支持按站点域名、发布时间等条件过滤。

请求参数(Query):

参数 类型 必填 说明
Query String 是 搜索关键词
Count Int32 否 返回数量,默认 10,最大 20
Filter String 否 高级过滤表达式(需 URL 编码)
SearchDB String 否 索引库:all(默认)、realtime(实时)、static(静态)

Filter 高级语法:

  • host=="example.com" — 按站点域名过滤
  • publish_time>=1778494631 — 按发布时间过滤(秒级时间戳)
  • 支持逻辑符:AND、OR,可用 () 控制优先级
  • 注意:host=="zhihu.com" 不支持,站内搜索请用 zhihu_search

Python 调用示例:

def global_search(query: str, count: int = 10, filter: str = "", search_db: str = "all"):
    """全网搜索"""
    url = "https://developer.zhihu.com/api/v1/content/global_search"
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "X-Request-Timestamp": str(int(time.time())),
        "Content-Type": "application/json",
    }
    params = {"Query": query, "Count": min(count, 20)}
    if filter:
        params["Filter"] = filter
    if search_db:
        params["SearchDB"] = search_db
    r = requests.get(url, params=params, headers=headers, timeout=15)
    r.raise_for_status()
    data = r.json()
    if data.get("Code") != 0:
        raise Exception(f"API Error: {data.get('Message')}")
    return data["Data"]

3. 知乎直答(AI 对话)

调用知乎直答 AI 模型进行对话问答,OpenAI SDK 兼容格式。

支持模型:

模型 说明
zhida-fast-1p5 快速回答,轻量响应
zhida-thinking-1p5 深度思考,含推理过程(reasoning_content)
zhida-agent 智能思考,Agent 模式

请求体(JSON):

{
  "model": "zhida-thinking-1p5",
  "messages": [
    {"role": "system", "content": "你是一个有帮助的助手"},
    {"role": "user", "content": "你好"}
  ],
  "stream": false
}

Python 调用示例:

def zhida_chat(messages: list, model: str = "zhida-fast-1p5", stream: bool = False):
    """知乎直答 AI 对话"""
    url = "https://developer.zhihu.com/v1/chat/completions"
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "X-Request-Timestamp": str(int(time.time())),
        "Content-Type": "application/json",
    }
    body = {"model": model, "messages": messages, "stream": stream}
    if stream:
        r = requests.post(url, json=body, headers=headers, timeout=60, stream=True)
        r.raise_for_status()
        for line in r.iter_lines(decode_unicode=True):
            if line and not line.startswith(":") and line != "data: [DONE]":
                print(line)
    else:
        r = requests.post(url, json=body, headers=headers, timeout=60)
        r.raise_for_status()
        return r.json()

响应字段(非流式):

字段 说明
choices[0].message.content 回答内容
choices[0].message.reasoning_content 推理过程(thinking 模型独有)

注意: zhida-agent 模型仅支持单轮 messages(仅 user),不支持 system/assistant 上下文。zhida-fast-1p5 和 zhida-thinking-1p5 支持多轮上下文。

4. 知乎热榜

获取当前知乎热榜内容列表。

请求参数(Query):

参数 类型 必填 说明
Limit Int32 否 返回数量,默认 30,最大 30

Python 调用示例:

def zhihu_hot_list(limit: int = 10):
    """获取知乎热榜"""
    url = "https://developer.zhihu.com/api/v1/content/hot_list"
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "X-Request-Timestamp": str(int(time.time())),
        "Content-Type": "application/json",
    }
    params = {"Limit": min(limit, 30)}
    r = requests.get(url, params=params, headers=headers, timeout=15)
    r.raise_for_status()
    data = r.json()
    if data.get("Code") != 0:
        raise Exception(f"API Error: {data.get('Message')}")
    return data["Data"]

响应字段(Item):

字段 说明
Title 热榜标题
Url 知乎链接
ThumbnailUrl 缩略图 URL
Summary 内容摘要

错误码

错误码 说明
0 成功
10001 参数错误
20001 鉴权失败
30001 频率限制
90001 内部错误

使用注意

  1. Access Secret 为敏感信息,Skill 中使用时通过环境变量或配置管理,不要硬编码在公开代码中
  2. X-Request-Timestamp 必须传当前秒级 Unix 时间戳
  3. 所有请求需设置 Content-Type: application/json
  4. 知乎搜索单次最多返回 10 条,全网搜索最多 20 条,热榜最多 30 条
  5. 全网搜索的 host 过滤不支持 zhihu.com 及其子域名,站内搜索请直接使用 zhihu_search

Current listing version

2.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value95/100

Highlights

  • 提供知乎开放平台API的完整调用能力,覆盖搜索、直答AI、热榜等核心功能
  • 满足开发者对知乎数据获取和AI对话的明确需求,实用价值高
Trigger Precision90/100

Highlights

  • 触发词覆盖全面,包含中英文关键词及功能描述,边界清晰
Structure and Standards90/100

Highlights

  • 文档结构清晰,接口说明完整,包含请求参数、示例代码和响应字段
  • frontmatter完整,版本号明确,标签合理
Execution Reliability90/100

Highlights

  • 提供完整的Python调用示例,包含错误处理和超时设置
  • 鉴权方式说明清晰,参数限制明确,异常处理覆盖主要场景
Evidence Verifiability (mean of the first four)91/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • developer.zhihu.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.