Process A Larger Note Batch Asynchronously
Synchronous batches are convenient for a small request. For up to 50 complete public note URLs, use the asynchronous workflow so the client does not hold one gateway request open.
Start with XHS Data API on RapidAPI and keep the RapidAPI key on your server.
Submit A Job
import os
import time
import requests
base_url = "https://xiaohongshu-rednote-data-api.p.rapidapi.com"
headers = {
"X-RapidAPI-Key": os.environ["X_RAPIDAPI_KEY"],
"X-RapidAPI-Host": "xiaohongshu-rednote-data-api.p.rapidapi.com",
"Content-Type": "application/json",
}
urls = [os.environ["XHS_NOTE_URL"]]
response = requests.post(
f"{base_url}/note/async_batch_detail_from_url",
headers=headers,
json={"urls": urls, "count": len(urls), "raw": False},
timeout=30,
)
response.raise_for_status()
job = response.json()["data"]
print("job_id:", job["job_id"])
Poll At The Recommended Interval
while job["status"] in {"queued", "running"}:
time.sleep(job.get("poll_after_seconds", 2))
response = requests.get(
f"{base_url}/note/async_batch_detail_result",
headers=headers,
params={"job_id": job["job_id"]},
timeout=30,
)
response.raise_for_status()
job = response.json()["data"]
print(job["status"], job["success"], job["failed"])
Stop polling when status is succeeded, partial, or failed. Results preserve per-item successes when another URL fails. Jobs process URLs sequentially, survive normal service restarts, and expire after 24 hours.
Never expose job_id as an authorization mechanism. Keep RapidAPI authentication server-side and store only the job metadata your application needs.
Download the complete clients and retry helpers from the developer website or review the public examples repository.
XHS Data API is independent and is not affiliated with or endorsed by Xiaohongshu/RedNote. Use public data lawfully and follow applicable law, third-party rights, and source-platform rules.
Top comments (0)