# RedNote (Xiaohongshu) Comments Scraper (`memo23/rednote-comments-scraper`) Actor

Scrape every comment on a RedNote / Xiaohongshu (小红书) note: text, author, likes, IP location, timestamps, and nested-reply samples. Paste the note URL (xsec\_token auto-captured) plus your web\_session cookie. Paginates the full thread. Chinese counts parsed to numbers.

- **URL**: https://apify.com/memo23/rednote-comments-scraper.md
- **Developed by:** [Muhamed Didovic](https://apify.com/memo23) (community)
- **Categories:** Social media
- **Stats:** 15 total users, 15 monthly users, 13.6% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## RedNote (Xiaohongshu) Comments Scraper

**Pull the full comment thread of any 小红书 note — comment text, author, likes, IP location, timestamps, and samples of nested replies — as clean JSON rows.**

Xiaohongshu gates its comments API behind login. With your `web_session` cookie the actor signs every request through Xiaohongshu's own web signing (x-s / x-t) in a headless page, seeds page 1 from the note page itself, then paginates the comment API until your page or item cap. Without a cookie it returns a **preview**: the first comment batch Xiaohongshu shows a guest (about 5 top-level comments with their replies), read from the mobile share page with no login at all.

> **No cookie? The rest of the RedNote suite needs none.** [Note Detail](https://apify.com/memo23/rednote-note-detail-scraper), [User Profile](https://apify.com/memo23/rednote-user-profile-scraper), [Trending & Category Feed](https://apify.com/memo23/rednote-trending-scraper), and [Product](https://apify.com/memo23/rednote-product-scraper) all run with no login. Comments and keyword search are the only two operations Xiaohongshu locks behind a logged-in session.

### What you get per comment

| Field | Description |
| --- | --- |
| `accessMode` | `full` for a cookie-backed paginated crawl, `preview` for the guest first batch |
| `commentId` | Comment ID |
| `content` | Comment text |
| `likeCount` / `likeCountNum` | Likes as shown (e.g. `1.2万`) and parsed to a number (12000) |
| `ipLocation` | Commenter's displayed IP region (e.g. 上海) |
| `createdAt` | ISO timestamp |
| `userId`, `userName`, `userAvatar` | Commenter profile |
| `subCommentCount` | Number of replies under this comment |
| `subCommentsSample` | Up to 5 nested replies: text, author, likes, IP location |

### How to run it

1. Copy a note URL from Xiaohongshu (e.g. `https://www.xiaohongshu.com/explore/<id>?xsec_token=…`) and paste it as the input — the `xsec_token` is captured from the URL automatically.
2. For the full thread, log in at [xiaohongshu.com](https://www.xiaohongshu.com), open DevTools → **Application** → **Cookies**, copy the `web_session` value, and paste it into the cookie field (marked secret, never logged). Skip this step for a preview of the first comments.
3. Set `maxPages` (~15–20 comments per page) and run.

### Example input

```json
{
    "noteId": "https://www.xiaohongshu.com/explore/644a3e3c00000000130085a0?xsec_token=ABw5H7OmT061JPr1RF2mmIQQ4v5auTThBae2wAf3wo17k=&xsec_source=pc_feed",
    "maxPages": 5,
    "webSession": "<your web_session value>"
}
```

### FAQ

**Do I need a cookie?** Not for a preview. Xiaohongshu shows a guest only the first batch of comments (about 5 top-level comments with up to 3 replies each), and that is what a run without a cookie returns, with rows marked `accessMode: "preview"`. Every comment API answers a login wall to a guest, so the full paginated thread needs your `web_session`. An expired cookie fails fast with a clear message instead of burning your budget on doomed requests.

**Where do I find notes to scrape?** Use the [RedNote Search Scraper](https://apify.com/memo23/rednote-search-scraper) — every search row includes the note URL + `xsec_token` ready to paste here.

**Does it get every nested reply?** Each comment row carries its `subCommentCount` plus a sample of up to 5 replies with text, author, likes, and IP location.

### Related scrapers

- [RedNote Search Scraper](https://apify.com/memo23/rednote-search-scraper) — keyword search, feeds this actor
- [RedNote Note Detail Scraper](https://apify.com/memo23/rednote-note-detail-scraper) — the note itself, no login needed
- [Xiaohongshu (RedNote) Scraper](https://apify.com/memo23/xiaohongshu-rednote-scraper) — the all-in-one actor: 8 operations including user profiles, channel feeds, and mall products

### 🤖 For AI Agents & LLM Apps

Compact reference for AI agents calling this actor via the [Apify MCP server](https://mcp.apify.com) or the Apify API (actor: `memo23/rednote-comments-scraper`).

**Purpose:** Paginates the full comment thread of one Xiaohongshu (RedNote / 小红书) note into JSON rows — comment text, author, likes, IP location, timestamps, and samples of nested replies.

**Minimal input:**

```json
{
  "noteId": "https://www.xiaohongshu.com/explore/644a3e3c00000000130085a0?xsec_token=ABw5H7OmT061JPr1RF2mmIQQ4v5auTThBae2wAf3wo17k=&xsec_source=pc_feed",
  "webSession": "<your web_session cookie value>",
  "maxPages": 2,
  "maxItems": 30
}
```

Cookie-free preview: send only `noteId` (and `maxItems`).

**Output:** one dataset row per comment; key fields: accessMode, commentId, content, likeCount, likeCountNum, ipLocation, createdAt, userId, userName, userAvatar, subCommentCount, subCommentsSample (up to 5 nested replies: text, author, likes, IP location).

**Behaviors an agent should know:**

- `webSession` is optional. Without it the run returns a preview: the first comment batch Xiaohongshu shows a guest (about 5 top-level comments with replies), rows marked `accessMode: "preview"`, no pagination. With a valid logged-in `web_session` cookie the run paginates the full thread (`accessMode: "full"`). An expired cookie fails fast with a clear message. `webSession` is marked secret and never logged.
- Always set `maxItems` (and/or `maxPages`, ~15–20 comments per page) to cap output; uncapped runs paginate the whole thread.
- Pass the full note URL as `noteId`; the `xsec_token` is extracted from it automatically. For a bare 24-hex ID, supply `xsecToken` separately.
- Find notes to feed in with the RedNote Search Scraper — each search row includes the note URL + `xsec_token`.
- Billing: Pay-per-event billing — see the Pricing tab on the actor page.

### ⚠️ Disclaimer

This actor collects publicly displayed data from Xiaohongshu for legitimate research, marketing, and archival purposes. You are responsible for complying with applicable laws, Xiaohongshu's terms, and for the account whose cookie you supply. Do not use collected data for spam or harassment.

# Actor input Schema

## `noteId` (type: `string`):

A 24-hex note ID, or a full note URL (…/explore/<id>?xsec\_token=…). Pasting the full URL also captures the xsec\_token automatically.

## `xsecToken` (type: `string`):

The xsec\_token that pairs with the note. Skip this if you pasted the full note URL above (the token is taken from it).

## `webSession` (type: `string`):

A logged-in Xiaohongshu `web_session` cookie value from an account you control. Log in at xiaohongshu.com, open DevTools → Application → Cookies, and copy the `web_session` value. You can paste either the bare value or your whole cookie string. Optional: without it the run returns a PREVIEW — roughly the first 5 top-level comments with their replies, which is all Xiaohongshu shows a guest. Paste a cookie for the full paginated thread.

## `maxPages` (type: `integer`):

Comment pages to fetch (~15–20 comments per page). Default 1.

## `maxItems` (type: `integer`):

Hard cap on total dataset rows. Leave empty for no cap.

## `proxy` (type: `object`):

Proxy egress. Leave default to use built-in residential routing. Override with Apify Proxy or custom proxy URLs if needed.

## Actor input object example

```json
{
  "noteId": "https://www.xiaohongshu.com/explore/644a3e3c00000000130085a0?xsec_token=ABw5H7OmT061JPr1RF2mmIQQ4v5auTThBae2wAf3wo17k=&xsec_source=pc_feed",
  "maxPages": 1,
  "proxy": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "noteId": "https://www.xiaohongshu.com/explore/644a3e3c00000000130085a0?xsec_token=ABw5H7OmT061JPr1RF2mmIQQ4v5auTThBae2wAf3wo17k=&xsec_source=pc_feed"
};

// Run the Actor and wait for it to finish
const run = await client.actor("memo23/rednote-comments-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "noteId": "https://www.xiaohongshu.com/explore/644a3e3c00000000130085a0?xsec_token=ABw5H7OmT061JPr1RF2mmIQQ4v5auTThBae2wAf3wo17k=&xsec_source=pc_feed" }

# Run the Actor and wait for it to finish
run = client.actor("memo23/rednote-comments-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "noteId": "https://www.xiaohongshu.com/explore/644a3e3c00000000130085a0?xsec_token=ABw5H7OmT061JPr1RF2mmIQQ4v5auTThBae2wAf3wo17k=&xsec_source=pc_feed"
}' |
apify call memo23/rednote-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,memo23/rednote-comments-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/EpQqhsLWrxaO152jo/builds/IqoPka6ktLI6G0Ctq/openapi.json
