RedNote (Xiaohongshu) API Quickstart with PHP
Xiaohongshu Data
API Tutorial
PHP
This tutorial connects you to the RedNote (Xiaohongshu) data API with PHP. You build no crawler — the Rnote API handles collection infrastructure, and you just send a GET request with an X-API-Key header via cURL. You can also follow the Python, Node.js, and Go versions.
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
<?php
$base = "https://rnote.dev/api/v2/crawler";
$query = http_build_query(["keyword" => "camping gear", "page" => 1]);
$ch = curl_init("$base/search/notes?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["X-API-Key: YOUR_API_KEY"],
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status === 200) {
$data = json_decode($response, true);
print_r($data);
}
Step 3: Wrap a function with retries
<?php
function call(string $path, array $params, int $retries = 3) {
$url = "https://rnote.dev/api/v2/crawler/$path?" . http_build_query($params);
for ($i = 0; $i < $retries; $i++) {
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["X-API-Key: YOUR_API_KEY"],
CURLOPT_TIMEOUT => 30,
]);
$resp = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status === 200) {
return json_decode($resp, true);
}
sleep(2 ** $i); // exponential backoff
}
throw new Exception("request failed after retries");
}
// e.g. fetch image-note details
print_r(call("note/image", ["note_id" => "697c0eee000000000a03c308"]));
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
- Bulk content: keyword search, watermark-free image/video
- Users & products: comment data, product data
- Full endpoints: API docs
Sign up free and send your first request with PHP now.