Back to Blog

RedNote (Xiaohongshu) API Quickstart with Node.js

Rnote API Team · · 71 views · 中文
Xiaohongshu Data API Tutorial Node.js

This tutorial gets you connected to the RedNote (Xiaohongshu) data API with Node.js. Like the Python version, you don't build any crawler — the Rnote API handles collection infrastructure, and you just send standard HTTP requests.

Step 1: Sign up and get an API key

Go to the sign-up page, create an account, verify your email, and get free credits plus your API key.

Step 2: Make your first request

Node.js 18+ ships with fetch built in — no extra dependencies:

const API_BASE = "https://rnote.dev/api/v2/crawler";
const HEADERS = { "X-API-Key": "YOUR_API_KEY" };

async function searchNotes(keyword) {
  const url = new URL(`${API_BASE}/search/notes`);
  url.searchParams.set("keyword", keyword);
  url.searchParams.set("page", "1");
  const res = await fetch(url, { headers: HEADERS });
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  return res.json();
}

searchNotes("camping gear").then(console.log);

Step 3: Wrap a client with retries

async function call(path, params, retries = 3) {
  const url = new URL(`https://rnote.dev/api/v2/crawler/${path}`);
  Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
  for (let i = 0; i < retries; i++) {
    const res = await fetch(url, { headers: { "X-API-Key": "YOUR_API_KEY" } });
    if (res.ok) return res.json();
    await new Promise(r => setTimeout(r, 2 ** i * 1000)); // exponential backoff
  }
  throw new Error("request failed after retries");
}

// e.g. fetch image-note details
call("note/image", { note_id: "697c0eee000000000a03c308" }).then(console.log);

Only successful (HTTP 2xx) requests are billed, so retries on failures cost nothing — add retry logic with confidence.

Pricing & credits

Billed per request, no monthly fee, no minimum; free credits on sign-up. See top-up options and current offers on the pricing page.

Next steps

Sign up free and send your first request with Node.js now.