Weibo's Official CLI Goes Open Source: 70+ APIs, One Command, Native AI Agent Hooks
Weibo Open Platform Official CLI Open-Sourced: 70+ APIs Available via Command Line, Native AI Agent Support
Environment Requirements: Node.js 18+ · Supports macOS / Linux / Windows
Tool URL:https://open.weibo.com/cli/index
Background
The conventional approach to calling Weibo's open APIs involves writing an HTTP client by hand: maintaining OAuth token refresh logic, handling pagination, implementing error retries. Authentication and infrastructure code typically account for over 70% of the entire script, with business logic being the minority.
The official CLI tool weibo-cli released by the Weibo Open Platform builds this infrastructure in, encapsulating the capabilities of the Weibo Open Platform into directly executable terminal commands, and serves as a native call entry point for AI Agents.
Core Capabilities: Covers 70+ interfaces including publishing, interaction, search, and trend analysis; supports JSON / Table / CSV output; can be directly integrated into Agent workflows as an MCP tool.
1. Installation & Authentication
1.1 Installation
# npm global install
npm install -g @weibo-ai/weibo-cli
# Or use the official installation script
curl -fsSL https://open.weibo.com/cli/install.sh | bash
# Verify installation version
weibo-cli version
1.2 Prerequisites
Before calling the APIs, you must complete the following steps on the Weibo Open Platform (order cannot be reversed):
| Step | Operation | Description |
|---|---|---|
| 1 | Developer Real-Name Verification | Submit verification on the 'Basic Info' page; authorization cannot be created without passing |
| 2 | Subscribe to a Plan or Trial | Select a plan on the 'Subscription' page to obtain quota and credits |
| 3 | Bind Local Device | Create an authorization on the 'Device Authorization' page, then execute the login command |
Status Check:
weibo-cli doctor # Check authentication and plan status item by item
weibo-cli me --output table # View current account, balance, and plan information
1.3 Login
# Desktop environment (Browser OAuth)
weibo-cli auth login
# Headless environment (SSH / Docker / CI)
weibo-cli auth login --device
1.4 Plan Details
| Plan | Quota | Price |
|---|---|---|
| Free | 5 times/hour, own data only | Free |
| Basic | 3,000 Credits | ¥29 / month |
| Plus | 7,500 Credits | ¥69 / month |
| Pro | 32,000 Credits | ¥299 / month |
| Ultra | 100,000 Credits | ¥899 / month |
2. Command System Overview
# List all available commands under the current plan
weibo-cli commands list --available
# View parameters, required fields, and applicable plans for a specific command
weibo-cli commands show search/keyword
The CLI covers six capability modules:
| Module | Typical Commands | Description |
|---|---|---|
| Content Publishing | notes publish · notes publish-video |
Image/text, video, long post publishing |
| Interaction Management | comments list · messages reply |
Comment reading and replying, private message distribution |
| Content Search | search keyword · search user |
Keyword, super topic, user search |
| Trend Analysis | search trending · topics hot |
Hot search list, topic heat structured output |
| Fan Profiling | users followers · users analytics |
Interactive fan characteristics and behavior analysis |
| Marketing Automation | campaign lottery · notes batch-publish |
Lottery, batch content distribution |
3. Typical Command Details
3.1 Keyword Content Search
Use Case: Competitor topic analysis, track heat assessment.
weibo-cli search keyword \
--query "sunscreen" \
--limit 20 \
--sort hot \
--output json > result.json
Parameter Description:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
--query |
string | ✅ | — | Search keyword |
--limit |
number | ❌ | 10 | Number of results, max 50 |
--sort |
enum | ❌ | hot |
hot (by heat) / new (by newest) |
--output |
enum | ❌ | table |
json / table / csv |
Output Example (--output json):
{
"notes": [
{
"id": "6631xxxx",
"title": "After 3 years of using sunscreen, I've summarized this lazy-person formula",
"likes": 42000,
"collects": 18500,
"author": "Skincare Researcher Xiao Lin"
}
]
}
3.2 Real-time Hot Search Trends
weibo-cli search trending \
--limit 20 \
--output json
Outputs a structured array containing rank, keyword, and heat fields, which can be piped directly to jq for secondary filtering.
4. AI Agent Integration
All commands of weibo-cli are machine-callable structured interfaces that can be directly embedded into Agent workflows within the user's authorization scope, without needing to wrap an additional API Wrapper.
Applicable Scenarios
- Periodically fetch the heat of specific topics to trigger content strategy updates
- Automatically search for notes based on hot search keywords and generate summary reports
- Classify comments by sentiment and batch mark content pending replies
Complete Example: Hotspot Monitoring + Automatic Report Generation
# Step 1: Get skincare-related hot search terms
weibo-cli search trending \
--limit 20 --output json \
| jq '[.[] | select(.keyword | contains("skincare"))]' > trending.json
# Step 2: Batch search notes based on hot search terms
KEYWORD=$(jq -r '.[0].keyword' trending.json)
weibo-cli search keyword \
--query "$KEYWORD" \
--limit 30 --output json > notes.json
# Step 3: Output to LLM to generate report (can interface with Claude / GPT, etc.)
cat notes.json | llm-cli summarize \
--prompt "Analyze the content distribution and interaction trends of the above notes, output a hot topic summary for today's skincare track"
Security Note: For write operations such as posting, commenting, and sending private messages, it is recommended to keep a manual confirmation node in the Agent workflow to avoid unintended execution due to instruction misunderstanding. Credentials (access token, refresh token) should not be committed to version control or appear in public logs. If you suspect a leak, revoke the corresponding session in the console under 'My Info' -> 'Authorization List'.
5. Practical Scenarios
Scenario 1: Topic Heat Monitoring & Alerting
Check hourly whether a specific keyword has entered the hot search list, and trigger a notification when the threshold is reached.
#!/bin/bash
# monitor_topic.sh
KEYWORD="AI Tool"
THRESHOLD=50000
HEAT=$(weibo-cli search trending \
--output json \
| jq --arg kw "$KEYWORD" \
'[.[] | select(.keyword | contains($kw))] | .[0].heat // 0')
if [ "$HEAT" -gt "$THRESHOLD" ]; then
curl -s -X POST "$FEISHU_WEBHOOK" \
-H "Content-Type: application/json" \
-d "{\"text\": \"[Alert] $KEYWORD current heat $HEAT, has exceeded threshold $THRESHOLD\"}"
fi
Add to crontab for scheduled execution:
0 * * * * /path/to/monitor_topic.sh
Scenario 2: Competitor Account Content Collection
Pull recent notes from a specified account and export to CSV for subsequent analysis.
# Get target account ID
weibo-cli users show \
--username "Target Account Nickname" \
--output json > target_user.json
USER_ID=$(jq -r '.id' target_user.json)
# Pull the latest 50 notes
weibo-cli notes list \
--user-id "$USER_ID" \
--limit 50 \
--output csv > notes_export.csv
echo "Collection complete, total $(wc -l < notes_export.csv) records"
Scenario 3: Comment Filtering & Auto-Reply
Filter comments containing specific keywords and handle them with a unified reply.
# Pull the latest 100 received comments
weibo-cli comments received \
--limit 100 \
--output json > comments.json
# Filter comments with inquiry intent
jq '[.[] | select(.content | test("how much|where to buy|how to buy|link"))]' \
comments.json > inquiry.json
COUNT=$(jq length inquiry.json)
echo "Filtered $COUNT inquiry-type comments"
# Batch reply (recommend dry-run first before execution)
jq -r '.[].id' inquiry.json | while read CID; do
weibo-cli comments reply \
--comment-id "$CID" \
--content "Thanks for your inquiry, feel free to DM for details~"
done
6. Summary
The core value of weibo-cli is shifting the infrastructure cost of API calls to the tool layer, allowing developers to focus solely on business logic. Native AI Agent support is its key differentiator from similar tools, making it suitable for scenarios that require orchestrating Weibo operations into automated workflows.
Before use, developer verification and plan subscription are required. Personal testing can start with the Free plan. weibo-cli doctor can quickly locate configuration issues.
Reference Links
- Official Documentation:
https://open.weibo.com/cli/index - User Manual:
https://open.weibo.com/cli/quickstart