Back to skills
SkillHub ClubAnalyze Data & AIFull StackBackendData / AI

xiaohongshu-api

小红书数据API - 通过TikHub获取小红书帖子、评论、用户信息 / Xiaohongshu Data API via TikHub

Packaged view

This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.

Stars
3,126
Hot score
99
Updated
March 20, 2026
Overall rating
C0.0
Composite score
0.0
Best-practice grade
B77.6

Install command

npx @skill-hub/cli install openclaw-skills-xiaohongshu-api

Repository

openclaw/skills

Skill path: skills/bombfuock/xiaohongshu-api

小红书数据API - 通过TikHub获取小红书帖子、评论、用户信息 / Xiaohongshu Data API via TikHub

Open repository

Best for

Primary workflow: Analyze Data & AI.

Technical facets: Full Stack, Backend, Data / AI.

Target audience: everyone.

License: Unknown.

Original source

Catalog source: SkillHub Club.

Repository owner: openclaw.

This is still a mirrored public skill entry. Review the repository before installing into production workflows.

What it helps with

  • Install xiaohongshu-api into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
  • Review https://github.com/openclaw/skills before adding xiaohongshu-api to shared team environments
  • Use xiaohongshu-api for development workflows

Works across

Claude CodeCodex CLIGemini CLIOpenCode

Favorites: 0.

Sub-skills: 0.

Aggregator: No.

Original source / Raw SKILL.md

---
name: xiaohongshu-api
description: 小红书数据API - 通过TikHub获取小红书帖子、评论、用户信息 / Xiaohongshu Data API via TikHub
metadata:
  version: 1.0.0
---

# 小红书数据API / Xiaohongshu API

基于TikHub获取小红书公开数据。

## 功能 / Features

- 📝 获取帖子详情 / Get post details
- 💬 获取评论 / Get comments
- 👤 获取用户信息 / Get user info
- 🔍 搜索帖子 / Search posts
- 🔥 获取热门 / Get trending

## 使用方法 / Usage

```bash
# 获取帖子
python xiaohongshu.py --post-id <帖子ID>

# 搜索
python xiaohongshu.py --search <关键词>

# 热门
python xiaohongshu.py --trending
```

## 配置 / Configuration

需要TikHub API Key(免费注册):
https://api.tikhub.io

```python
TIKHUB_API_KEY = "your_api_key"
```

## API示例 / Examples

```python
from xiaohongshu import XiaohongshuAPI

api = XiaohongshuAPI(api_key="your_key")

# 获取帖子
post = api.get_post("67c8a0ed0000000001f00e2b")

# 搜索
results = api.search("AI教程")

# 热门
trending = api.get_trending()
```

## 注意事项

- 仅获取公开数据
- 遵守TikHub使用条款
- 尊重用户隐私


---

## Skill Companion Files

> Additional files collected from the skill directory layout.

### _meta.json

```json
{
  "owner": "bombfuock",
  "slug": "xiaohongshu-api",
  "displayName": "Xiaohongshu Api",
  "latest": {
    "version": "1.0.0",
    "publishedAt": 1772688280041,
    "commit": "https://github.com/openclaw/skills/commit/a6c274dab659196eaca120eb4493a6be7f9434a7"
  },
  "history": []
}

```

### scripts/xiaohongshu.py

```python
#!/usr/bin/env python3
"""
小红书API - 基于TikHub
"""
import requests
import json
import argparse

class XiaohongshuAPI:
    def __init__(self, api_key=None):
        self.api_key = api_key or ""
        self.base_url = "https://api.tikhub.io/api/v1"
        
    def get_post(self, post_id):
        """获取帖子详情"""
        url = f"{self.base_url}/xiaohongshu/web/post/detail"
        params = {"post_id": post_id}
        headers = {"X-TikHub-Api-Key": self.api_key} if self.api_key else {}
        
        try:
            resp = requests.get(url, params=params, headers=headers, timeout=10)
            return resp.json()
        except Exception as e:
            return {"error": str(e)}
    
    def search(self, keyword, page=1):
        """搜索帖子"""
        url = f"{self.base_url}/xiaohongshu/web/post/search"
        params = {"keyword": keyword, "page": page}
        headers = {"X-TikHub-Api-Key": self.api_key} if self.api_key else {}
        
        try:
            resp = requests.get(url, params=params, headers=headers, timeout=10)
            return resp.json()
        except Exception as e:
            return {"error": str(e)}
    
    def get_trending(self):
        """获取热门"""
        url = f"{self.base_url}/xiaohongshu/web/post/hot"
        headers = {"X-TikHub-Api-Key": self.api_key} if self.api_key else {}
        
        try:
            resp = requests.get(url, headers=headers, timeout=10)
            return resp.json()
        except Exception as e:
            return {"error": str(e)}

def main():
    parser = argparse.ArgumentParser(description='小红书API')
    parser.add_argument("--post", help="帖子ID")
    parser.add_argument("--search", help="搜索关键词")
    parser.add_argument("--trending", action="store_true", help="热门帖子")
    parser.add_argument("--api-key", help="TikHub API Key")
    
    args = parser.parse_args()
    
    api = XiaohongshuAPI(args.api_key)
    
    if args.post:
        result = api.get_post(args.post)
        print(json.dumps(result, indent=2, ensure_ascii=False))
    elif args.search:
        result = api.search(args.search)
        print(json.dumps(result, indent=2, ensure_ascii=False))
    elif args.trending:
        result = api.get_trending()
        print(json.dumps(result, indent=2, ensure_ascii=False))
    else:
        parser.print_help()

if __name__ == "__main__":
    main()

```