XHS Data APIOpen in RapidAPI
All guides

Batch tutorial

Process a larger note batch asynchronously

Keep gateway requests short while one durable worker processes up to 50 public note URLs sequentially.

Submit a job

import os
import time
import requests

base_url = "https://xhs-data-api.p.rapidapi.com"
headers = {
    "X-RapidAPI-Key": os.environ["X_RAPIDAPI_KEY"],
    "X-RapidAPI-Host": "xhs-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 successful items when another URL fails. Jobs process URLs sequentially, survive normal service restarts, and expire after 24 hours.

A job_id is a locator, not an authorization mechanism. Keep RapidAPI authentication server-side and store only the job metadata your application needs.