Loxifi.CurlImpersonate
1.3.1
Prefix Reserved
dotnet add package Loxifi.CurlImpersonate --version 1.3.1
NuGet\Install-Package Loxifi.CurlImpersonate -Version 1.3.1
<PackageReference Include="Loxifi.CurlImpersonate" Version="1.3.1" />
<PackageVersion Include="Loxifi.CurlImpersonate" Version="1.3.1" />
<PackageReference Include="Loxifi.CurlImpersonate" />
paket add Loxifi.CurlImpersonate --version 1.3.1
#r "nuget: Loxifi.CurlImpersonate, 1.3.1"
#:package Loxifi.CurlImpersonate@1.3.1
#addin nuget:?package=Loxifi.CurlImpersonate&version=1.3.1
#tool nuget:?package=Loxifi.CurlImpersonate&version=1.3.1
Loxifi.CurlImpersonate
A .NET wrapper around curl-impersonate that provides browser fingerprint impersonation for HTTP requests. This library implements an HttpClient-like API for seamless integration with existing .NET code while providing anti-fingerprinting capabilities.
What is curl-impersonate?
curl-impersonate is a special build of curl that can impersonate the four major browsers: Chrome, Firefox, Safari, and Edge. Unlike standard HTTP clients, it mimics the TLS fingerprint, HTTP/2 settings, and headers of real browsers, making it much harder for servers to detect that requests are coming from an automated tool rather than a real browser.
Installation
dotnet add package Loxifi.CurlImpersonate
Or via the NuGet Package Manager:
Install-Package Loxifi.CurlImpersonate
Quick Start
using Loxifi.CurlImpersonate;
// Create a client that impersonates Chrome 131
using var client = new CurlClient(BrowserProfile.Chrome131);
// Make requests just like HttpClient
HttpResponseMessage response = await client.GetAsync("https://example.com");
string content = await response.Content.ReadAsStringAsync();
Features
- HttpClient-compatible API - Familiar methods like
GetAsync,PostAsync,SendAsync - 31 Browser Profiles - Chrome, Firefox, Safari, Edge, and Tor profiles
- Cookie Support - Automatic cookie handling with
CookieContainer - Redirect Control - Follow redirects automatically or inspect 3xx responses directly
- Proxy Support - HTTP/HTTPS proxy with authentication
- SSL Certificate Handling - Includes CA certificate bundle for production use
- Auto-updating Profiles - Code generator tool to pull latest curl-impersonate releases
Usage Examples
Basic GET Request
using var client = new CurlClient(BrowserProfile.Chrome131);
string html = await client.GetStringAsync("https://example.com");
POST Request with JSON
using var client = new CurlClient(BrowserProfile.Firefox135);
var content = new StringContent(
"{\"username\":\"test\",\"password\":\"secret\"}",
Encoding.UTF8,
"application/json"
);
HttpResponseMessage response = await client.PostAsync("https://api.example.com/login", content);
Inspecting Redirect Responses
Redirects are followed automatically by default. Disable automatic redirects to inspect the
original status code and Location header:
using var client = new CurlClient(BrowserProfile.Chrome131)
{
AllowAutoRedirect = false
};
HttpResponseMessage response = await client.GetAsync("https://example.com/redirect");
if (response.StatusCode == HttpStatusCode.Found)
{
Uri? destination = response.Headers.Location;
}
Custom Headers
using var client = new CurlClient(BrowserProfile.Safari180);
// Add default headers sent with every request
client.DefaultRequestHeaders["Authorization"] = "Bearer your-token";
client.DefaultRequestHeaders["X-Custom-Header"] = "CustomValue";
var response = await client.GetAsync("https://api.example.com/data");
Using Cookies
using var client = new CurlClient(BrowserProfile.Chrome131);
// Add cookies manually
client.CookieContainer.Add(
new Uri("https://example.com"),
new Cookie("session", "abc123")
);
// Cookies from responses are automatically stored
await client.GetAsync("https://example.com/login");
// Subsequent requests include stored cookies
await client.GetAsync("https://example.com/dashboard");
// Disable cookie handling if needed
client.UseCookies = false;
Using a Proxy
using var client = new CurlClient(BrowserProfile.Chrome131);
// Simple proxy
client.Proxy = new WebProxy("http://proxy.example.com:8080");
// Proxy with authentication
client.Proxy = new WebProxy("http://proxy.example.com:8080")
{
Credentials = new NetworkCredential("username", "password")
};
var response = await client.GetAsync("https://example.com");
Base Address
using var client = new CurlClient(BrowserProfile.Chrome131);
client.BaseAddress = new Uri("https://api.example.com");
// Relative URLs are combined with BaseAddress
var users = await client.GetStringAsync("/users");
var posts = await client.GetStringAsync("/posts");
Timeout Configuration
using var client = new CurlClient(BrowserProfile.Chrome131);
client.Timeout = TimeSpan.FromSeconds(60);
Insecure Mode (Skip SSL Verification)
// WARNING: Only use for testing with self-signed certificates
using var client = new CurlClient(BrowserProfile.Chrome131);
client.Insecure = true;
Available Browser Profiles
Chrome
Chrome99,Chrome99AndroidChrome100,Chrome101,Chrome104,Chrome107Chrome110,Chrome116,Chrome119,Chrome120Chrome123,Chrome124,Chrome131,Chrome131AndroidChrome133a,Chrome136
Firefox
Firefox133,Firefox135
Safari
Safari153,Safari155,Safari170Safari172iOS,Safari180,Safari180iOSSafari184,Safari184iOS,Safari260,Safari260iOS
Edge
Edge99,Edge101
Tor
Tor145
API Reference
CurlClient
| Property | Type | Description |
|---|---|---|
BaseAddress |
Uri? |
Base URI for relative requests |
Timeout |
TimeSpan |
Request timeout (default: 100 seconds) |
DefaultRequestHeaders |
IDictionary<string, string> |
Headers sent with every request |
CookieContainer |
CookieContainer |
Cookie storage for the client |
UseCookies |
bool |
Enable/disable cookie handling (default: true) |
Proxy |
WebProxy? |
Proxy configuration |
Insecure |
bool |
Skip SSL certificate verification (default: false) |
| Method | Description |
|---|---|
GetAsync(string/Uri) |
Send GET request |
PostAsync(string/Uri, HttpContent) |
Send POST request |
PutAsync(string/Uri, HttpContent) |
Send PUT request |
DeleteAsync(string/Uri) |
Send DELETE request |
PatchAsync(string/Uri, HttpContent) |
Send PATCH request |
SendAsync(HttpRequestMessage) |
Send custom request |
GetStringAsync(string/Uri) |
GET and return string |
GetByteArrayAsync(string/Uri) |
GET and return byte array |
GetStreamAsync(string/Uri) |
GET and return stream |
Updating Browser Profiles
This library includes a code generator tool that automatically pulls the latest curl-impersonate release from GitHub and regenerates the browser profile code.
To update to the latest profiles:
# Windows
Update.bat
# Or manually
dotnet run --project src/Loxifi.CurlImpersonate.CodeGen
This will:
- Download the latest curl-impersonate release
- Extract the native binaries and bat files
- Parse the bat files to extract browser fingerprint settings
- Generate updated
BrowserProfile.csandBrowserProfileSettings.cs
Platform Support
Currently supports:
- Windows x64 (
win-x64)
The native curl-impersonate binaries are included in the NuGet package and automatically copied to the output directory.
How It Works
Browser Profile Selection: Each profile contains the exact TLS ciphers, curves, HTTP/2 settings, and headers used by that browser version.
curl-impersonate Execution: Requests are executed via the bundled curl-impersonate binary with the appropriate flags.
Response Parsing: The curl output is parsed and converted to standard
HttpResponseMessageobjects.Cookie Management: Cookies are automatically extracted from responses and sent with subsequent requests.
Credits
This project is a .NET wrapper around the excellent curl-impersonate project by lexiforest.
curl-impersonate is a special build of curl that performs TLS and HTTP handshakes identical to real browsers. It is based on:
- curl - The underlying HTTP client
- Modified TLS libraries (BoringSSL/NSS) to mimic browser TLS fingerprints
License
This project is licensed under the MIT License.
curl-impersonate is licensed under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
See Also
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.