Back to Blog

RedNote (Xiaohongshu) API Quickstart with C# / .NET

Rnote API Team · · 51 views · 中文
Xiaohongshu Data API Tutorial C#

This tutorial connects you to the RedNote (Xiaohongshu) data API with C# (.NET). You build no crawler — the Rnote API handles collection infrastructure, and you just send a GET request with an X-API-Key header using .NET's built-in HttpClient. You can also follow the Python, Node.js, Go, Java, and PHP 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

.NET 6+ top-level statements with the built-in HttpClient, no third-party deps:

using System.Net.Http;
using System.Web;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY");

var query = HttpUtility.UrlEncode("camping gear");
var url = $"https://rnote.dev/api/v2/crawler/search/notes?keyword={query}&page=1";

var resp = await client.GetAsync(url);
Console.WriteLine((int)resp.StatusCode);
Console.WriteLine(await resp.Content.ReadAsStringAsync());

Once that works, swap the endpoint for note/image (image-note details), user/info (creator info), and more — see the API docs for parameters.

Step 3: Wrap a call with retries

using System.Net;
using System.Web;

static readonly HttpClient Http = new();

static async Task<string> Call(string path, Dictionary<string, string> p, int retries = 3)
{
    var qs = string.Join("&", p.Select(kv =>
        $"{kv.Key}={HttpUtility.UrlEncode(kv.Value)}"));
    var url = $"https://rnote.dev/api/v2/crawler/{path}?{qs}";

    for (var i = 0; i < retries; i++)
    {
        using var req = new HttpRequestMessage(HttpMethod.Get, url);
        req.Headers.Add("X-API-Key", "YOUR_API_KEY");
        var resp = await Http.SendAsync(req);
        if (resp.StatusCode == HttpStatusCode.OK)
            return await resp.Content.ReadAsStringAsync();
        await Task.Delay((int)Math.Pow(2, i) * 1000); // exponential backoff
    }
    throw new Exception("request failed after retries");
}

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 C# now.