Aident AI

How to Fetch Xiaohongshu Data in Batches With Aident Loadout
Yes, a client can use Aident Loadout from server-side code to fetch Xiaohongshu, also known as RedNote, notes and account data in batches. Log in with the Loadout CLI, export the short-lived access_token as AIDENT_TOKEN, preflight every distinct request shape, and call the production HTTP endpoints described by the public Xiaohongshu OpenAPI schema.
This tutorial is for a developer building a batch worker, research pipeline, or internal data-enrichment job. By the end, you will have one authenticated Node.js client, a bounded note-detail batch, a bounded keyword-search batch, and a clear record of estimated and actual Loadout credit usage.
What You Can Fetch
The production action set exposed these operations when it was inspected on August 11, 2026:
Action | Job | Production estimate on August 11, 2026 |
|---|---|---|
| Fetch one account profile | 0.65 credits |
| Fetch one note by ID or link | 0.65 credits |
| Search accounts by keyword | 0.65 credits |
| Search notes by keyword | 0.65 credits |
| Query the broader Xiaohongshu database | 0.65 credits |
| Start comment collection | 0.975 credits |
| Poll a comment task | Free |
| Start video-to-copy extraction | 9.747 credits |
| Poll an extraction task | Free |
Prices and schemas can change. The estimate is dated evidence, not a permanent price list. Preflight the exact action and input before execution, especially for a large batch.
RedFox access for this action set is managed by Aident. The client does not need to supply a separate RedFox API key or sign in to a Xiaohongshu account. Xiaohongshu also operates official platforms for mini apps, sharing, advertising, and commerce. Those platforms serve different jobs from this public-content retrieval workflow.
Prerequisites
An Aident account with permission to use Loadout and enough credits for the batch.
A trusted macOS or Linux machine.
Node.js 18 or newer for the examples.
Server-side or worker-side execution. Never put
AIDENT_TOKENin browser JavaScript.A reviewed collection policy covering the data you are allowed to retrieve, retain, and process.
1. Install Loadout and Log In
Follow https://aident.ai/SETUP.md
For a named client, run first-time setup against production:
If setup is already complete, refresh the login:
On a terminal without a usable browser, add --oob. Open the displayed URL on a trusted device, authorize the client, and paste only the authorization code into the waiting terminal.
Confirm the session before doing anything billable:
The expected response has success: true, data.authenticated: true, and the intended Aident account identity.
2. Find AIDENT_TOKEN Without Printing It
After login, the CLI stores its OAuth credentials in ~/.aident/credentials.json. The value needed for the HTTP Authorization header is access_token. It is not client_id or refresh_token.
Refresh the CLI-managed session, then export the access token without displaying it:
The last command succeeds without revealing the token. Keep shell tracing off because set -x can expose expanded headers. For a deployed worker, use the platform's secret manager instead of copying a developer token into source or configuration files.
Access tokens expire. Before each direct-HTTP batch, run aident account auth status --json and export the current access_token again. Do not share a developer refresh token among services.
3. Download the Public OpenAPI Contract
The client-focused OpenAPI 3.1 document is public at:
Download it into the client project:
The schema defines authentication status, metadata, preflight, execution, and audit operations plus all nine action input variants. It also binds the exact Loadout capability discriminator required by the API. Generate an SDK from this document or let the sample resolve the discriminator from the checked-in copy instead of hardcoding an internal identifier from an old article.
This small Node command reads that constant from the downloaded schema without printing a credential:
4. Create a Shared Preflight-First Client
Save this as loadout-xiaohongshu.mjs:
The helper deliberately stops when preflight requests explicit credit approval. Approval must come from the client and must apply to the exact input-bound request. Do not turn a one-time approval token into a standing budget bypass.
5. Sample One: Fetch a Bounded Batch of Note Details
Save this as fetch-note-details.mjs:
Run it with:
Each row should contain the stable client ID, the preflight estimate, execution duration, and raw provider output. The provider output is intentionally open-ended in the schema, so preserve the raw object and version any downstream normalization separately.
Send exactly one of workId or workLink. The current server schema permits an identifier-free request, but a client should reject it before submission.
6. Sample Two: Search Notes Across Several Keywords
Save this as search-notes.mjs:
Run it with:
Keep keyword count, concurrency, pagination, and time windows bounded. Record which input produced each output so failed rows can be retried without replaying the entire batch.
For larger database queries, use parse_work_query_xhs_ai_msgs and set keyword, pageNum, pageSize, startTime, and endTime explicitly. Do not inherit time defaults in a scheduled job.
7. Inspect Usage After the Batch
The public contract also includes the Loadout audit operation. Ask for recent usage from your own account and filter it to the relevant integration or request source. Reconcile the returned rows with your stable client IDs, estimates, successful outputs, and failures.
Preflight is not the receipt. It validates and estimates. The audit and the returned execution envelope are the evidence that a call actually ran.
Common Failures
401 or an unauthenticated status
Run aident login, then aident account auth status --json. Export the newly refreshed access_token again. Confirm the worker is using the production base URL and the intended account.
validation-error
Compare the input with the current public schema and live metadata. Check the action name, required fields, and primitive types. For note details, include exactly one stable identifier.
credit-approval-required
Stop and present the estimate to the client. If approved, use only the one-time, input-bound approval token returned for that request. The sample stops intentionally rather than approving spend automatically.
requires-user-acknowledgement
Stop and show the risk message and allowed acknowledgement scopes. Credit approval and risk acknowledgement are separate decisions.
A submit action returns a task ID
Comment collection and video-to-copy extraction are asynchronous. Store the returned task ID, then poll the matching result action with bounded backoff. Do not resubmit the paid starter action merely because the result is not ready yet.
The output shape changes
Treat raw provider output as an external contract. Preserve it, validate the fields your application needs, and version your normalization layer. Do not silently coerce missing fields to plausible values.
Production Checklist
Before scheduling a large batch:
Confirm the Aident account and token are current.
Download or regenerate the client from the current OpenAPI schema.
Preflight every distinct action and input shape.
Set hard limits for items, pages, date windows, concurrency, timeouts, and credits.
Require explicit approval when preflight asks for it.
Persist stable client IDs, task IDs, estimates, envelopes, and audit receipts.
Retry only retryable rows, with bounded backoff and idempotent bookkeeping.
Keep credentials server-side and redact authorization headers from logs.
Collect only data the client is authorized to use, and apply retention and privacy controls.
For the wider integration model, see How to Use Aident Loadout, MCP vs API, and How to Give AI Agents API Access Without Exposing Keys.
Set up Aident Loadout for a bounded Xiaohongshu batch, then generate your client from the public OpenAPI contract.
Refresh Triggers
Refresh this guide when the public schema, action list, pricing, authentication flow, approval contract, or official Xiaohongshu platform boundaries change, or when complete owned search evidence identifies a narrower reader job that deserves its own canonical page.
Sources
Live Aident Loadout catalog, authentication status, preflight, and Vault status, inspected August 11, 2026



The one tool
for every tool
your agent needs.
Give any AI agent real capabilities in seconds. Connect 1,000+ tools once, skip the setup headache, and let your agents execute.
