@dawnswwwww/zhihu-cli
v0.1.4
Published
CLI for the Zhihu Open Platform API
Readme
zhihu-cli
CLI for the Zhihu Open Platform API.
Supports authentication, Zhihu search, global web search, and the Zhida chat completion API.
Installation
From npm (recommended for Agent environments)
npm install -g @dawnswwwww/zhihu-cli
zhihu --helpFrom Homebrew
brew tap dawnswwwww/tap
brew install zhihu-cliFrom crates.io
cargo install zhihu-cliFrom GitHub Releases
Download the prebuilt archive for your platform from the Releases page, extract it, and place the zhihu binary in your PATH.
Quick start
# Authenticate with your Access Secret
zhihu auth login
# Or set it directly
zhihu auth set-secret <YOUR_ACCESS_SECRET>
# Search Zhihu
zhihu search zhihu "Rust 入门" --count 5
# Search the whole web
zhihu search global "Rust 入门" --count 5
# Ask Zhida
zhihu ask "Rust 和 Go 怎么选?" --model thinkingClaude Skill
This repository includes a Claude skill to help you use zhihu-cli from Claude Code or Claude.ai.
Install it with the Skills CLI:
# Install from GitHub
npx skills add dawnswwwww/zhihu-cli
# Or install globally
npx skills add dawnswwwww/zhihu-cli -gOnce installed, Claude will automatically use the skill whenever you ask about searching Zhihu, using the Zhida API, or configuring zhihu-cli.
Commands
| Command | Description |
|---------|-------------|
| zhihu auth login | Interactive login (reads secret from stdin). |
| zhihu auth set-secret <SECRET> | Save Access Secret directly. |
| zhihu auth status | Show authentication status. |
| zhihu search zhihu <QUERY> | Search within Zhihu. |
| zhihu search global <QUERY> | Search the whole web. |
| zhihu ask <QUERY> | Ask Zhida. Use --model fast/thinking/agent and --stream. |
Run zhihu --help or zhihu <command> --help for details.
Configuration
The CLI stores configuration (including the Access Secret) under the user's config directory, typically:
- macOS/Linux:
~/.config/zhihu-cli/config.toml - Windows:
%APPDATA%\zhihu-cli\config.toml
You can also override the secret at runtime with the ZHIHU_ACCESS_SECRET environment variable.
Development
# Run tests
make test
# Lint
make lint
# Full local CI check
make checkSee docs/development.md for the full workflow.
Release
Pushing a SemVer tag triggers the release workflow:
git tag -a v0.1.3 -m "Release 0.1.3"
git push origin v0.1.3This builds cross-platform binaries, creates a GitHub Release, publishes zhihu-cli to npm, and updates the Homebrew tap.
