# Xiaohongshu Note Comments Scraper (`opspilot.cc/xiaohongshu-note-comments-scraper`) Actor

Fetch the public comment list for a Xiaohongshu note by note\_id or share\_text. Supports pagination (page 1-10) with cursor + index + pageArea tokens and three sort strategies.

- **URL**: https://apify.com/opspilot.cc/xiaohongshu-note-comments-scraper.md
- **Developed by:** [wang wei](https://apify.com/opspilot.cc) (community)
- **Categories:** E-commerce, SEO tools, Social media
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.10 / actor start

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

## Xiaohongshu Note Comments Scraper

Fetch the public comment list for a Xiaohongshu note by `note_id` or `share_text`. Supports cursor-based pagination (page 1–10) with three sort strategies: latest, most liked, or default.

> When both `note_id` and `share_text` are provided, `note_id` wins.

### Use it together with the other Xiaohongshu Actors

This Actor is one piece of a 4-piece Xiaohongshu toolkit. Run them in sequence to go from a topic, to a single note detail, to its comment thread.

| Where in the pipeline | Actor | Console | Use it to |
|---:|---|---|---|
| before / step ① | [Xiaohongshu Keyword Search Scraper](https://console.apify.com/actors/JECW4SdwsOOgtuobc) | [JECW4SdwsOOgtuobc](https://console.apify.com/actors/JECW4SdwsOOgtuobc) | step ① — discover `noteId`s by keyword |
| sister Actor / step ② | [Xiaohongshu Image Note Detail Scraper](https://console.apify.com/actors/kP7I5XcMAaLxaYj0R) | [kP7I5XcMAaLxaYj0R](https://console.apify.com/actors/kP7I5XcMAaLxaYj0R) | step ② — pair with this Actor for the parent note's metadata (title / images / author) |
| after / step ③ | [Xiaohongshu Video Note Detail Scraper](https://console.apify.com/actors/nIGSWsYF5htLotphk) | [nIGSWsYF5htLotphk](https://console.apify.com/actors/nIGSWsYF5htLotphk) | step ② — same, but for the parent video note |

**You are here:** **Xiaohongshu Note Comments Scraper** (step ③) — run this on its own for `pull the full comment thread (cursor-paginated)`. The other 3 Actors live in their own Apify listings — click their Console links to open them in a new tab.

### No Setup Required

> **No setup required.** The upstream API key and base URL are preconfigured in this Actor — no Environment variables to add, no Console setup steps to follow. Just click **Start** and fill in the input form.

> **Schema changed?** Apify Console caches the input form. Click **Reload editor** (or hard-refresh) to pick up new fields after a schema bump.

### Why Use This Actor

| Problem | How This Actor Solves It |
|---|---|
| You have a Xiaohongshu note URL and want to monitor or archive the comment thread. | Pass the URL as `share_text`; get a normalized dataset of comments with author, engagement, and timestamps. |
| You want deeper data than a single page. | User-driven pagination: pass the next-page `cursor` / `index` / `pageArea` tokens returned by the previous run. |
| You want to sort comments differently. | Pick `latest_v2` (recommended), `like_count`, or `default`. |

### What You Get

A normalized dataset with one row per unique comment:

- **Identifiers** — `commentId`, `noteId`, `targetCommentId` (for replies)
- **Content** — `content`, `publishTime`, `publishTimeText`, `ipLocation`
- **Engagement** — `likedCount`, `subCommentCount`, `isAuthor`, `isLiked`
- **Author** — `userId`, `nickname`, `avatar`, plus `targetUserNickname` for replies
- **Provenance** — `page`, `rank`, `sortStrategy`, `collectedAt`, `rawData`

Plus a SUMMARY record with the page count, request count, dedup count, and the next-page tokens.

### Quick Start

#### 1. Run with Example Input

```json
{
  "note_id": "697c0eee000000000a03c308",
  "page": 1,
  "sort_strategy": "latest_v2"
}
```

Or paste the full app share text:

```json
{
  "share_text": "美食 https://www.xiaohongshu.com/explore/abc?xsec_token=xyz 复制打开",
  "page": 1,
  "sort_strategy": "latest_v2"
}
```

#### 2. Paginate to the next page

After the first run, the SUMMARY record contains `nextCursor`, `nextIndex`, and `nextPageArea`. Pass them back as inputs for the next run:

```json
{
  "note_id": "697c0eee000000000a03c308",
  "page": 2,
  "cursor": "<paste nextCursor>",
  "index": <paste nextIndex>,
  "pageArea": "UNFOLDED",
  "sort_strategy": "latest_v2"
}
```

#### 3. Export Your Results

The dataset is available as a JSON array; the SUMMARY record is in the default key-value store.

### Input Reference

#### `note_id` — Note ID

| Required | Type | Description |
|---|---|---|
| Optional (one of two) | string | Xiaohongshu note ID, up to 64 alphanumeric characters. Wins over `share_text` when both are provided. |

#### `share_text` — Share text

| Required | Type | Description |
|---|---|---|
| Optional (one of two) | string | A Xiaohongshu share link or the full share text from the app. up to 2000 characters; the Actor extracts the first http(s) URL. Use when you don't have the raw note\_id. |

#### `page` — Page number

| Required | Type | Description |
|---|---|---|
| Optional | integer 1–10 | Default 1. Each page = one upstream request. |

#### `cursor` — Pagination cursor

| Required (page >= 2) | Type | Description |
|---|---|---|
| Optional | string | From the previous run's `nextCursor`. Leave blank for page 1. |

#### `index` — Comment index

| Required (page >= 2) | Type | Description |
|---|---|---|
| Optional | integer ≥ 0 | From the previous run's `nextIndex`. Use 0 for the first page. |

#### `pageArea` — Fold status

| Required (page >= 2) | Type | Description |
|---|---|---|
| Optional | enum `UNFOLDED` / `FOLDED` | Default `UNFOLDED`. From the previous run's `nextPageArea`. |

#### `sort_strategy` — Sort order

| Required | Type | Description |
|---|---|---|
| Optional | enum `latest_v2` / `like_count` / `default` | Default `latest_v2` (recommended for stable pagination). `default` is not recommended because pagination may skip or duplicate comments. |

### Output Reference

See "What You Get" above for the full field list. Each row also includes `rawData`, the unmodified upstream payload, for audit and re-parsing.

### Pricing & Limits

- **Free tier**: 5 runs/day (each run = up to 10 upstream requests).
- **Paid users**: Unlimited runs.
- **Hard caps**: 10 pages per run (configurable via `MAX_PAGES_HARD_CAP`).
- **Note about default sort**: `default` may cause pagination to skip or duplicate comments; prefer `latest_v2`.

### FAQ

- **How do I paginate?** After each run, copy `nextCursor`, `nextIndex`, and `nextPageArea` from the SUMMARY, then re-run with `page = current + 1` and the new tokens.
- **My free run is blocked?** Free tier is 5 runs/day. Upgrade your Apify plan, wait until tomorrow, or set `APIFY_USER_IS_PAYING=1`.
- **Can I sort by hot / engagement?** `like_count` sorts by likes (desc). `default` is upstream-default but unstable across pages.
- **What happens if the upstream returns no comments on page 2?** The Actor stops and reports the previous page's `nextCursor` in the SUMMARY, so you don't lose pagination state.
- **Do I need to add an upstream API key?** No. This Actor ships with the upstream integration preconfigured — `UPSTREAM_API_KEY` and `UPSTREAM_BASE_URL` are baked into the build. No Console setup, no secrets to manage.

### Support

Open an issue on the [Actor Console page](https://console.apify.com/actors/) or contact via Discord linked in the upstream SUMMARY.

### Actor

- **Apify Actor ID**: `LNXEA0uuHX70vchNW`
- **Console**: <https://console.apify.com/actors/LNXEA0uuHX70vchNW>

### Changelog

See [CHANGELOG.md](./CHANGELOG.md).

# Actor input Schema

## `note_id` (type: `string`):

Xiaohongshu note ID, for example: 697c0eee000000000a03c308. Preferred over share\_text. If both are provided, note\_id wins. Default value is used when the Actor is invoked with empty input so Apify automated tests can run without manual setup.

## `share_text` (type: `string`):

Paste a Xiaohongshu share link or the full share text from the app. The Actor extracts the first http(s) URL automatically. Use this only when you do not have a raw note\_id.

## `page` (type: `integer`):

Page number, start from 1. The Actor calls upstream once per page, so page=3 makes 3 upstream requests. The default of 1 keeps every run cheap.

## `cursor` (type: `string`):

Required when page >= 2. Copy from the previous run SUMMARY field `nextCursor` (or the first item's `rawData.cursor`). Leave blank for page = 1.

## `index` (type: `integer`):

Required when page >= 2. Comment index from the previous run, e.g. the SUMMARY `nextIndex` or first item's `rawData.index`. Use 0 for the first page.

## `pageArea` (type: `string`):

Required when page >= 2. Fold status from the previous run. Use `UNFOLDED` (expanded, the default) for the first page.

## `sort_strategy` (type: `string`):

How comments are ranked. `latest_v2` is the recommended default — time desc with stable pagination. `default` is not recommended because paginating may cause missing or duplicate comments.

## Actor input object example

```json
{
  "note_id": "697c0eee000000000a03c308",
  "share_text": "",
  "page": 1,
  "cursor": "",
  "index": 0,
  "pageArea": "UNFOLDED",
  "sort_strategy": "latest_v2"
}
```

# Actor output Schema

## `dataset` (type: `string`):

One normalized dataset item per unique comment, with the original upstream payload preserved in rawData.

## `summary` (type: `string`):

note\_id, sort\_strategy, pages fetched, unique comments, requests, error details, and the next-page cursor / index / pageArea tokens for further pagination.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("opspilot.cc/xiaohongshu-note-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("opspilot.cc/xiaohongshu-note-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 '{}' |
apify call opspilot.cc/xiaohongshu-note-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,opspilot.cc/xiaohongshu-note-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/LNXEA0uuHX70vchNW/builds/9ZGXtE0taoI0RN1RM/openapi.json
