# How to get a keyword's search index and related keywords on Xiaohongshu PGY

2 endpoints do it: Xiaohongshu PGY related keywords → Xiaohongshu PGY keyword search index. The worked example below is 3 calls and costs $0.12 in all; a failed call is not charged.

Start from one keyword: get its related keywords on PGY (蒲公英, Xiaohongshu's creator marketplace), each with its rank and search index, then the day-by-day search index, notes, impressions, views and engagements of your keyword and the ones you pick. You end up with one table by day of how those words are doing on Xiaohongshu.

## Step by step

### Step 1: Xiaohongshu PGY related keywords

Ask for one keyword and its related keywords on PGY come back in one call, with no paging. Each item's `keyword` is the related word, `rank` its rank, `search_index` its search index and `relation` how it is related. Pick the words to follow and take their `keyword` into the next step. ([Xiaohongshu PGY related keywords](https://dataxapi.com/apis/xiaohongshu/pgy/keywords/related/), $0.0400 / a call)

cURL

```bash
curl -G "https://api.dataxapi.com/v1/xiaohongshu/pgy/keywords/related" \
  --data-urlencode "keyword=面膜" \
  -H "Authorization: Bearer $DATAXAPI_API_KEY"
```

Python

```python
# pip install dataxapi
from dataxapi import DataXAPI

dx = DataXAPI()  # reads DATAXAPI_API_KEY
result = dx.xiaohongshu.pgy.keywords.related(keyword="面膜")
print(result["data"]["items"])
```

TypeScript

```typescript
// npm i @dataxapi/sdk
import { DataXAPI } from "@dataxapi/sdk";

const dx = new DataXAPI(); // reads DATAXAPI_API_KEY
const result = await dx.xiaohongshu.pgy.keywords.related({ keyword: "面膜" });
console.log(result.data.items);
```

CLI

```bash
dataxapi call xiaohongshu.pgy.keywords.related 'keyword=面膜'
```

Recorded response: From a response recorded 2026-10-12 21:42 UTC. Names, text and IDs are examples, and so are the links: none is the recorded one (the page shows no one's personal data); the figures are as recorded. Long lists are cut. The request ID, cursor and balance are made up.

```jsonc
{
  "code": "ok",
  "request_id": "14b8ced1-2b33-47f6-90f7-86463f68684e",
  "data": {
    "items": [
      {
        "keyword": "烧烤",
        "related_to": "露营",
        "relation": "prior",
        "rank": 1,
        "search_index": 2638774
      },
      // … 97 more
    ]
  },
  "page": {
    "next_cursor": null,
    "cursor_expires_at": null,
    "has_more": false,
    "returned": 98
  },
  "warnings": [],
  "meta": {
    "capability": "xiaohongshu.pgy.keywords.related",
    "result_status": "complete",
    "fetched_at": "2026-10-12T21:42:15.000Z",
    "cached": false,
    "replayed": false,
    "unavailable": {
      "relevance": "platform",
      "composite_index": "platform"
    },
    "billing": {
      "amount": "0.04",
      "currency": "USD",
      "balance_after": "9.96"
    }
  }
}
```

### Step 2: Xiaohongshu PGY keyword search index

One keyword a call: put it into `keyword` and one item comes back, whose `points` hold the daily `search_index`, `notes`, `impressions`, `views` and `engagements`. Call once for each word. ([Xiaohongshu PGY keyword search index](https://dataxapi.com/apis/xiaohongshu/pgy/keywords/history/), $0.0400 / a call)

cURL

```bash
curl -G "https://api.dataxapi.com/v1/xiaohongshu/pgy/keywords/history" \
  --data-urlencode "keyword=面膜" \
  -H "Authorization: Bearer $DATAXAPI_API_KEY"
```

Python

```python
# pip install dataxapi
from dataxapi import DataXAPI

dx = DataXAPI()  # reads DATAXAPI_API_KEY
result = dx.xiaohongshu.pgy.keywords.history(keyword="面膜")
print(result["data"]["item"])
```

TypeScript

```typescript
// npm i @dataxapi/sdk
import { DataXAPI } from "@dataxapi/sdk";

const dx = new DataXAPI(); // reads DATAXAPI_API_KEY
const result = await dx.xiaohongshu.pgy.keywords.history({ keyword: "面膜" });
console.log(result.data.item);
```

CLI

```bash
dataxapi call xiaohongshu.pgy.keywords.history 'keyword=面膜'
```

Recorded response: From a response recorded 2026-10-12 21:42 UTC. Names, text and IDs are examples, and so are the links: none is the recorded one (the page shows no one's personal data); the figures are as recorded. Long lists are cut. The request ID, cursor and balance are made up.

```jsonc
{
  "code": "ok",
  "request_id": "5303d79c-7963-4548-a038-ec91bd3cae60",
  "data": {
    "item": {
      "keyword": "露营",
      "points": [
        {
          "date": "2026-07-13T00:00:00Z",
          "search_index": 8876,
          "notes": 33361,
          "impressions": 25229649,
          "views": 4523846,
          "engagements": 188216
        },
        {
          "date": "2026-07-14T00:00:00Z",
          "search_index": 8762,
          "notes": 33750,
          "impressions": 24457001,
          "views": 4743520,
          "engagements": 197829
        },
        {
          "date": "2026-07-15T00:00:00Z",
          "search_index": 9077,
          "notes": 33603,
          "impressions": 24578646,
          "views": 4554487,
          "engagements": 210434
        },
        {
          "date": "2026-07-16T00:00:00Z",
          "search_index": 9328,
          "notes": 34232,
          "impressions": 28302245,
          "views": 4819305,
          "engagements": 220431
        },
        {
          "date": "2026-07-17T00:00:00Z",
          "search_index": 11233,
          "notes": 34532,
          "impressions": 32434694,
          "views": 5831644,
          "engagements": 278646
        },
        {
          "date": "2026-07-18T00:00:00Z",
          "search_index": 12636,
          "notes": 34772,
          "impressions": 35466179,
          "views": 6122704,
          "engagements": 279193
        },
        {
          "date": "2026-07-19T00:00:00Z",
          "search_index": 11490,
          "notes": 35368,
          "impressions": 37495492,
          "views": 8187198,
          "engagements": 302141
        },
        // … 85 more
      ]
    }
  },
  "warnings": [],
  "meta": {
    "capability": "xiaohongshu.pgy.keywords.history",
    "result_status": "complete",
    "fetched_at": "2026-10-12T21:42:12.000Z",
    "cached": false,
    "replayed": false,
    "unavailable": { "points.composite_index": "platform" },
    "billing": {
      "amount": "0.04",
      "currency": "USD",
      "balance_after": "9.96"
    }
  }
}
```

## What the example costs

One keyword's related keywords, then the daily figures of that keyword and the top related one, two words in all

| Endpoint | Calls | Price | Subtotal |
| --- | --- | --- | --- |
| [Xiaohongshu PGY related keywords](https://dataxapi.com/apis/xiaohongshu/pgy/keywords/related/) | 1 | $0.0400 | $0.0400 |
| [Xiaohongshu PGY keyword search index](https://dataxapi.com/apis/xiaohongshu/pgy/keywords/history/) | 2 | $0.0400 | $0.0800 |
| Total | 3 |  | $0.12 |

Prices are the prices in force when this page was built. A failed call costs nothing.

## In your AI (MCP)

Connect DataXAPI to your AI client once. Then say what you want; the agent finds these endpoints, checks the price and calls them on your balance.

Say: On Xiaohongshu PGY, get the related keywords of 防晒 (sunscreen), pick the top one, and get the daily search index, notes and engagements of it and 防晒, as one table.

What the agent sends to the call tool: 

```json
{
  "capability": "xiaohongshu.pgy.keywords.related",
  "keyword": "面膜",
  "idempotency_key": "<a new UUID>"
}
```

[About the MCP server](https://dataxapi.com/mcp/)

## Good to know

- A search index is PGY's own index, not a number of searches. Compare a keyword with its own past, or with another keyword on Xiaohongshu.
- The related-keywords endpoint is charged when it finds nothing; the daily-index endpoint returns an empty result when it does not know the word, and that is not charged.
- Days are calendar days in China time (UTC+8).

## The whole script

The task above as one script that runs as it is: Python, the SDK, your key from DATAXAPI_API_KEY. It writes a CSV file and ends by printing what it called, fetched and was charged.

```python
# pip install dataxapi
# export DATAXAPI_API_KEY=dx_...   (your key)
import csv
from decimal import Decimal
from dataxapi import DataXAPI

dx = DataXAPI()
calls, fetched, charged = 0, 0, Decimal("0")

def run(capability, params):
    """One call; counts it and what it was charged."""
    global calls, charged
    result = dx.call(capability, params)
    calls += 1
    charged += Decimal(str(result["meta"]["billing"]["amount"]))
    return result

KEYWORD = "防晒"
MORE = 1

# 1. The keyword's related keywords on PGY, each with its search index.
related = run("xiaohongshu.pgy.keywords.related", {"keyword": KEYWORD})["data"]["items"]
words = [KEYWORD] + [each["keyword"] for each in sorted(related, key=lambda each: each.get("rank", 0))[:MORE]]

# 2. Each word's daily search index, notes, impressions, views and engagements.
rows = []
for word in words:
    item = run("xiaohongshu.pgy.keywords.history", {"keyword": word})["data"]["item"]
    if item:
        for point in item["points"]:
            rows.append([item["keyword"], point["date"], point.get("search_index"), point.get("notes"), point.get("impressions"), point.get("views"), point.get("engagements")])

fetched = len(rows)
with open("pgy-keywords.csv", "w", newline="", encoding="utf-8") as file:
    csv.writer(file).writerows([["keyword", "date", "search_index", "notes", "impressions", "views", "engagements"], *rows])

print(f"calls: {calls}, items: {fetched}, charged: ${charged}")
```

Run for real on 2026-10-29: 3 calls, 182 rows written, $0.12 charged. A failed call is not charged.

## Endpoints

- [Xiaohongshu PGY related keywords](https://dataxapi.com/apis/xiaohongshu/pgy/keywords/related/)
- [Xiaohongshu PGY keyword search index](https://dataxapi.com/apis/xiaohongshu/pgy/keywords/history/)

## More about Xiaohongshu (RedNote)

- [Xiaohongshu (RedNote) API](https://dataxapi.com/apis/xiaohongshu/)
- [Xiaohongshu PGY API](https://dataxapi.com/apis/xiaohongshu/pgy/)
- [How to get Xiaohongshu (RedNote) note comments in bulk](https://dataxapi.com/guides/xiaohongshu-note-comments/)
- [How to look up Xiaohongshu (RedNote) PGY creator rates and audience](https://dataxapi.com/guides/xiaohongshu-pgy-creator-rates/)
- [How to search and export Xiaohongshu (RedNote) notes by keyword](https://dataxapi.com/guides/xiaohongshu-search-export-notes/)
- [How do I export Xiaohongshu (RedNote) data?](https://dataxapi.com/answers/export-xiaohongshu-data/)
- [Can ChatGPT read Xiaohongshu (RedNote)?](https://dataxapi.com/answers/can-chatgpt-read-xiaohongshu/)
- [What is xsec_token on Xiaohongshu?](https://dataxapi.com/answers/xiaohongshu-xsec-token/)
- [What is a Xiaohongshu note ID, and what is an xhslink link?](https://dataxapi.com/answers/xiaohongshu-note-id-and-xhslink/)
- [What is CPE on Xiaohongshu PGY and on Douyin Xingtu?](https://dataxapi.com/answers/xiaohongshu-pgy-cpe-vs-xingtu-cpe/)
- [What is Xiaohongshu PGY?](https://dataxapi.com/answers/what-is-xiaohongshu-pgy/)

---

Catalog revision 5c3194deef3264cc. [HTML version](https://dataxapi.com/guides/xiaohongshu-pgy-keywords/)
