# How can I collect Xiaohongshu data without cookies or scanning a QR code every day?

> Xiaohongshu scrapers need a logged-in cookie that expires and a QR scan to renew it. How to run a scheduled Xiaohongshu job on a server with only an API key.

Canonical page: https://okdata.online/answers/xiaohongshu-scrape-without-cookie-login/

**Short answer: **Use an API that does not run on your login. With okdata a scheduled job sends only an API key, so there is no cookie to expire and no QR code to scan; a daily keyword pull of three search pages costs $0.06, and a creator's latest notes $0.02 per page.

Most Xiaohongshu tools work like this: open a browser, scan a QR code with your phone, save the cookie, run. That is fine on a laptop on Tuesday afternoon. It falls apart when the job should run at 7 am on a server: the cookie expires after some days, the scan has to be repeated by a person, the tool sometimes reports "no login info" right after a successful scan, and some accounts get logged out after a handful of searches. A whole category of plugins now exists just to refresh cookies. Running the job on an API key instead of a login removes both the cookie and the QR scan.

## Run it on a key instead

With okdata your server holds one API key in an environment variable. The key does not expire on its own, and no browser or phone is involved, so the job can live in cron, GitHub Actions or a serverless function.

- [Xiaohongshu note search](/apis/xiaohongshu/notes/search/): new notes for a keyword, `sort=latest`.
- [Xiaohongshu account notes](/apis/xiaohongshu/users/notes/list/): one creator's notes, newest first, about 20 per page.

## A daily job and its bill

| Daily task | Calls | Per day | Per 30 days |
|---|---|---|---|
| One keyword, 3 pages | 3 | $0.06 | $1.80 |
| 5 creators, first page | 5 | $0.10 | $3.00 |

## Cron-ready script

```python
# 0 7 * * *  python3 xhs_daily.py >> xhs.csv
import csv, os, sys, requests

r = requests.get(
    "https://api.okdata.online/v1/xiaohongshu/notes/search",
    headers={"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
    params={"query": "露营 装备", "sort": "latest", "fields": "id,title,published_at,metrics.likes,url"},
    timeout=60,
)
r.raise_for_status()
out = csv.writer(sys.stdout)
for n in r.json()["data"]["items"]:
    out.writerow([n["id"], n["title"], n["published_at"], n["metrics"]["likes"], n["url"]])
```

If a call fails, the error body says whether it was charged (never, for failures) and whether to retry. Rate-limit headers (`X-RateLimit-Remaining`) tell a loop when to slow down. Details on the [errors page](/docs/errors/).

## What does not come with it

- Logged-in data: your own feed, saved notes, private notes and messages.
- View counts, which Xiaohongshu never shows publicly; `metrics.views` is null.
- The creator's name inside the account notes list. It is the account you asked for; call the [account profile](/apis/xiaohongshu/users/get/) once if you need it.

## When logging in is still right

If you manage your own brand account and want its private analytics, Xiaohongshu's creator center and its official open platform are the proper source, and they do require your login. For public notes on a schedule, a key is less work than a cookie. The [trend research](/solutions/trend-research/) page shows a daily keyword routine.

## Endpoints used

- [Xiaohongshu note search](https://okdata.online/apis/xiaohongshu/notes/search/) `xiaohongshu.notes.search`: $0.02 per call · about 20 notes per page
- [Xiaohongshu account notes](https://okdata.online/apis/xiaohongshu/users/notes/list/) `xiaohongshu.users.notes.list`: $0.02 per call · about 20 notes per page

Updated 2026-11-12
