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 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.
curl -G "https://api.dataxapi.com/v1/xiaohongshu/pgy/keywords/related" \ --data-urlencode "keyword=面膜" \ -H "Authorization: Bearer $DATAXAPI_API_KEY"
# pip install dataxapi from dataxapi import DataXAPI dx = DataXAPI() # reads DATAXAPI_API_KEY result = dx.xiaohongshu.pgy.keywords.related(keyword="面膜") print(result["data"]["items"])
// 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);
dataxapi call xiaohongshu.pgy.keywords.related 'keyword=面膜'{
"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"
}
}
}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.
Xiaohongshu PGY related keywords · $0.0400 / a call · Parameters, fields and errors on the endpoint's page →
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.
curl -G "https://api.dataxapi.com/v1/xiaohongshu/pgy/keywords/history" \ --data-urlencode "keyword=面膜" \ -H "Authorization: Bearer $DATAXAPI_API_KEY"
# pip install dataxapi from dataxapi import DataXAPI dx = DataXAPI() # reads DATAXAPI_API_KEY result = dx.xiaohongshu.pgy.keywords.history(keyword="面膜") print(result["data"]["item"])
// 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);
dataxapi call xiaohongshu.pgy.keywords.history 'keyword=面膜'{
"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"
}
}
}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.
Xiaohongshu PGY keyword search index · $0.0400 / a call · Parameters, fields and errors on the endpoint's page →
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
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.
{
"capability": "xiaohongshu.pgy.keywords.related",
"keyword": "面膜",
"idempotency_key": "<a new UUID>"
}Sign in to copy the setup prompt with your keyAbout the MCP server →
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.
# 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.