Inside the Unofficial API: How xhs Is Reshaping Access to Xiaohongshu Data

GitHub June 2026
⭐ 2177
Source: GitHubArchive: June 2026
A new open-source Python library, xhs, is gaining traction among developers for its clean interface to Xiaohongshu's web API. But as it crosses 2,100 GitHub stars, questions about legality, platform enforcement, and the future of third-party data access are coming to a head.

The xhs project (GitHub: reajason/xhs) is a Python wrapper that abstracts the complexities of Xiaohongshu's web-based API, enabling developers to programmatically retrieve public content such as posts, user profiles, and search results. With over 2,177 stars and a daily growth rate of zero (suggesting a mature, stable user base), it has become a go-to tool for researchers, marketers, and analysts seeking to mine the platform's rich user-generated content. The library's appeal lies in its simplicity: it handles authentication, request signing, and rate limiting, allowing users to focus on data extraction rather than reverse engineering. However, its existence sits in a legal gray area. Xiaohongshu's terms of service explicitly prohibit scraping, and the company has invested in anti-bot measures. The xhs project's documentation includes a disclaimer urging compliance, but enforcement remains inconsistent. This article examines the technical underpinnings, real-world use cases, and the broader implications for data access in the age of walled gardens. We also compare xhs to similar tools for other platforms, such as TikTok's unofficial APIs, to contextualize the trend. Ultimately, the project highlights a fundamental tension: the demand for open data versus platforms' control over their ecosystems. As AI and data analysis become more central to business strategy, tools like xhs will either force platforms to offer legitimate APIs or drive a cat-and-mouse game of detection and evasion.

Technical Deep Dive

The xhs library operates by mimicking the behavior of a legitimate web browser. It sends HTTP requests to Xiaohongshu's internal API endpoints, which are used by the web frontend (xhs.cn). The key technical challenge is that Xiaohongshu, like most modern web platforms, employs request signing and anti-bot mechanisms. The library's core innovation is its implementation of the signature algorithm, which is reverse-engineered from the platform's JavaScript code. This involves extracting the logic that generates the `X-s` and `X-t` headers, which are required for every authenticated request. The library handles cookie management, session persistence, and automatic token refresh, making it appear as a persistent, legitimate user session.

The library's architecture is straightforward: it exposes a high-level `Client` class with methods like `get_note_by_id()`, `search_notes()`, and `get_user_profile()`. Under the hood, it uses the `requests` library for HTTP and `pycryptodome` for cryptographic operations. The signature algorithm is a combination of MD5 hashing, timestamp encoding, and a secret key that is periodically rotated by Xiaohongshu. The project's maintainer, reajason, has documented this process in the repository's wiki, but the actual implementation is obfuscated to avoid easy detection.

Performance and Limitations:

| Metric | Value | Notes |
|---|---|---|
| Requests per second (with rate limiting) | ~2-5 | Library includes built-in delay to avoid IP bans |
| Average response time (single request) | 0.8-1.5s | Dependent on network and server load |
| Data fields per note | ~30 | Includes text, images, likes, comments, tags |
| Maximum search results per query | 100 | Pagination limited by platform |
| Account suspension risk | Moderate | Heavy usage triggers CAPTCHA |

Data Takeaway: The library's performance is adequate for small-to-medium scale projects (e.g., monitoring 100-500 notes/day), but it is not designed for high-frequency scraping. The rate limiting is a necessary evil to avoid detection, but it also caps the utility for large-scale research.

A notable open-source alternative is `xhs-scraper` (GitHub: xhs-scraper/xhs-scraper), which uses Playwright for browser automation. This approach is more robust against signature changes but is significantly slower (0.5-1 request per second) and more resource-intensive. The xhs library's advantage is its lightweight nature—it can run on a serverless function or a low-cost VPS.

Key Players & Case Studies

The primary developer is reajason, a pseudonymous Chinese developer with a history of creating tools for social media data extraction. Their GitHub profile shows contributions to similar projects for Weibo and Douyin, indicating a specialization in Chinese platform APIs. The xhs project has attracted contributions from about 15 other developers, mostly for bug fixes and documentation improvements.

Use Cases:

1. Academic Research: A team at Tsinghua University used xhs to analyze consumer sentiment around electric vehicles in China, collecting over 50,000 posts over three months. Their study, published in a peer-reviewed journal, correlated post sentiment with sales data from BYD and NIO.

2. Brand Monitoring: A marketing agency in Shanghai uses xhs to track competitor campaigns. They scrape hashtag-specific content daily and feed it into a sentiment analysis pipeline using Hugging Face's BERT models. The agency reports a 30% reduction in manual monitoring costs.

3. Content Creators: Individual influencers use the library to analyze trending topics and optimize posting times. One creator with 200k followers shared on a forum that they use xhs to find underperforming content with high engagement potential.

Comparison with Similar Tools:

| Tool | Platform | Method | Stars | Maintenance Status |
|---|---|---|---|---|
| xhs (reajason) | Xiaohongshu | Direct API wrapper | 2,177 | Active (last commit 2 weeks ago) |
| TikTokApi (DavidTeather) | TikTok | Direct API + Playwright | 4,500 | Active |
| Instagram-scraper (realsirjoe) | Instagram | Selenium-based | 3,200 | Stale (no updates in 6 months) |
| Weibo-crawler (dataabc) | Weibo | Direct API | 1,800 | Active |

Data Takeaway: The xhs project is part of a broader ecosystem of unofficial API tools. Its star count is modest compared to TikTok's equivalent, but this reflects Xiaohongshu's smaller global user base, not a lack of demand. The maintenance activity is a positive sign—many similar projects are abandoned after platform updates break the scraping logic.

Industry Impact & Market Dynamics

The rise of tools like xhs signals a growing demand for data from platforms that lack official, affordable APIs. Xiaohongshu, valued at over $20 billion in its last funding round (2023), has not released a public API for content access. This creates a vacuum that third-party tools fill, but it also poses risks for both the platform and users.

Market Data:

| Year | Estimated Number of xhs Users | Cumulative GitHub Stars | Reported Scraping Incidents (Xiaohongshu) |
|---|---|---|---|
| 2022 | 500 | 200 | 10 |
| 2023 | 2,000 | 800 | 50 |
| 2024 (H1) | 5,000 | 2,177 | 120 |

*Note: User numbers are rough estimates based on download counts and forum mentions. Scraping incidents are from public reports on Chinese tech forums.*

Data Takeaway: The rapid growth in both users and incidents suggests that Xiaohongshu is becoming more aggressive in enforcement, but the tool's user base continues to expand. This is a classic arms race: as detection improves, so do evasion techniques.

Business Model Impact:

For data brokers and analytics firms, xhs lowers the barrier to entry. A startup can now build a sentiment analysis product for Xiaohongshu without negotiating a data licensing deal, which typically costs $50,000-$200,000 per year. This democratizes access but also commoditizes the data. Established players like Meltwater and Brandwatch, which rely on official partnerships, face pressure to justify their premium pricing.

For Xiaohongshu itself, the proliferation of scraping tools erodes its ability to monetize its data. The company has been exploring a data licensing business, but if high-quality data is freely available via scraping, that revenue stream is undermined. This is likely why we have seen increased CAPTCHA challenges and IP blocking in recent months.

Risks, Limitations & Open Questions

Legal Risks:

The most immediate risk is legal action. Xiaohongshu's terms of service explicitly prohibit scraping. In 2023, a Chinese court ruled in favor of a platform (Weibo) in a similar case, ordering a scraper developer to pay damages. The xhs project's disclaimer does not provide legal protection; it merely shifts responsibility to the user. Developers using the library for commercial purposes could face cease-and-desist letters or lawsuits.

Technical Limitations:

The library's reliance on reverse-engineered signatures is fragile. Xiaohongshu can change the algorithm at any time, breaking the library. The project's maintainer has been responsive, but there is no guarantee of continued support. Additionally, the library cannot access private accounts or encrypted content, limiting its use for comprehensive analysis.

Ethical Concerns:

Scraping public data is often considered acceptable, but the line blurs when data is aggregated and sold. There is also the issue of consent: users posting on Xiaohongshu may not expect their content to be scraped and analyzed by third parties. The European Union's GDPR and China's Personal Information Protection Law (PIPL) impose strict requirements on data processing, even for public data. A researcher scraping user profiles could inadvertently violate these laws if they collect personal data without a lawful basis.

Open Questions:

1. Will Xiaohongshu eventually release an official API? The company has not announced any plans, but the growing demand may force their hand.
2. How will AI-generated content affect scraping? As Xiaohongshu integrates more AI features (e.g., AI-powered recommendations), the data landscape may shift, making scraping less useful.
3. Can the open-source community sustain this tool? The maintainer is a single developer; burnout or legal pressure could end the project.

AINews Verdict & Predictions

The xhs project is a double-edged sword. On one hand, it empowers researchers and small businesses to gain insights from a platform that is otherwise opaque. On the other hand, it operates in a legal gray zone that could lead to significant consequences for its users.

Our Predictions:

1. Short-term (6-12 months): Xiaohongshu will deploy more aggressive anti-scraping measures, including dynamic signature changes and browser fingerprinting. The xhs library will likely require frequent updates, and some users will be blocked. However, the tool will remain functional for low-volume use.

2. Medium-term (1-2 years): A major legal case will set a precedent. Either Xiaohongshu will sue a commercial user of xhs, or a developer will be targeted. The outcome will shape the future of scraping in China. We predict the platform will win, leading to a chilling effect on similar projects.

3. Long-term (2-5 years): Xiaohongshu will launch a paid API for enterprise customers, offering limited data access at a premium. This will legitimize some use cases but leave small players out. The xhs project will either pivot to a legal scraping model (e.g., using browser automation with user consent) or become obsolete.

What to Watch:

- The GitHub repository's issue tracker: a sudden spike in "signature error" reports will signal a platform update.
- Chinese tech news for any legal actions related to scraping.
- The emergence of alternative tools that use browser automation (e.g., Playwright) as a more robust but slower approach.

In conclusion, xhs is a testament to the ingenuity of the open-source community, but it also highlights the fragility of data access in a platform-dominated internet. The future will be shaped by legal battles, technical arms races, and the evolving priorities of Xiaohongshu itself.

More from GitHub

UntitledSpider_XHS, a GitHub repository with over 6,500 stars and a staggering daily growth of 883 stars, has become the go-to oUntitledLogto has emerged as a formidable open-source contender in the identity and access management (IAM) space, directly chalUntitledBackrest is an open-source project that wraps the powerful but notoriously complex restic command-line backup tool in a Open source hub3173 indexed articles from GitHub

Archive

June 20263062 published articles

Further Reading

Trafilatura: The Open-Source Tool Quietly Dominating Web Text ExtractionTrafilatura, a lightweight Python and command-line tool for web text and metadata extraction, is gaining traction for itHome Assistant's Awesome List: The Hidden Engine Powering the Smart Home RevolutionA single GitHub repository, maintained by a core developer, has become the indispensable compass for navigating the spraCloudflare's workerd: The Open Source Engine Reshaping Edge Computing's FrontierCloudflare has open-sourced workerd, the core runtime engine behind its globally distributed Workers platform. This movePaper-QA: The Open-Source Tool That Could Fix Scientific AI Hallucinations for GoodPaper-QA is an open-source retrieval-augmented generation (RAG) tool that answers questions from scientific PDFs while a

常见问题

GitHub 热点“Inside the Unofficial API: How xhs Is Reshaping Access to Xiaohongshu Data”主要讲了什么?

The xhs project (GitHub: reajason/xhs) is a Python wrapper that abstracts the complexities of Xiaohongshu's web-based API, enabling developers to programmatically retrieve public c…

这个 GitHub 项目在“xhs python library scraping legal”上为什么会引发关注?

The xhs library operates by mimicking the behavior of a legitimate web browser. It sends HTTP requests to Xiaohongshu's internal API endpoints, which are used by the web frontend (xhs.cn). The key technical challenge is…

从“xhs vs xiaohongshu official api”看,这个 GitHub 项目的热度表现如何?

当前相关 GitHub 项目总星标约为 2177,近一日增长约为 0,这说明它在开源社区具有较强讨论度和扩散能力。