A powerful HTTP client for Node.js based on libcurl with browser fingerprinting capabilities.
curl-cffi is a high-performance HTTP client library for Node.js built on libcurl. It provides synchronous and asynchronous request methods with powerful browser fingerprinting capabilities, making it ideal for web scraping, API testing, and automation tasks that require browser simulation.
- Multiple Request Modes: Support for synchronous and asynchronous requests
- Browser Fingerprinting: Simulate various browsers including Chrome, Firefox, Safari, Edge, and Tor
- Session Management: Maintain cookies and configurations across requests
- Rich Configuration Options: Comprehensive control over HTTP requests
- JA3/TLS Fingerprinting: Advanced TLS fingerprint simulation
- Web scraping with browser simulation
- API testing and integration
- Automated web interactions
- Network request debugging
- Bypassing basic anti-bot measures
npm install curl-cffi
const { req } = require("curl-cffi");
// Asynchronous request
async function makeGetRequest() {
try {
const response = await req.get("https://api.example.com/data", {
impersonate: "chrome136", // Simulate Chrome 136
});
console.log("Status Code:", response.statusCode);
console.log("Response Data:", response.data);
} catch (error) {
console.error("Request failed:", error);
}
}
makeGetRequest();
curl-cffi supports synchronous and asynchronous request modes:
// Synchronous request
const { CurlRequestSync, CurlRequest, CurlMultiImpl } = require("curl-cffi");
const req = new CurlRequestSync();
// Asynchronous request implementation
const req2 = new CurlRequest();
// Multi-based asynchronous request
const req3 = new CurlClient({
// Enable multi requests, which will reuse connections, not reused by default
impl: new CurlMultiImpl(),
});
// Session request
const req1 = new CurlSession();
// Asynchronous request without connection reuse
const req2 = new CurlSessionSync();
type RequestOptions = {
method?: RequestMethod,
url?: string,
params?: Record<string, any>,
// Request data
data?: Record<string, any> | string | null,
// Cookie jar
jar?: CookieJar,
// Request headers
headers?: Record<string, string>,
auth?: RequestAuth,
timeout?: number,
allowRedirects?: boolean,
maxRedirects?: number,
// Proxy http://username:password@host:port
proxy?: string,
referer?: string,
acceptEncoding?: string,
// Enable curl fingerprint
impersonate?: CURL_IMPERSONATE,
ja3?: string,
akamai?: string,
defaultHeaders?: boolean,
defaultEncoding?: string,
httpVersion?: HttpVersion | number,
interface?: string,
cert?: string | RequestCert,
verify?: boolean,
maxRecvSpeed?: number,
curlOptions?: Record<CurlOpt, string | number | boolean>,
ipType?: IpType,
// Enable multi, which will reuse requests, not reused by default
impl?: CurlMultiImpl,
// Automatic retry count, default 0
retryCount?: number,
keepAlive?: boolean,
// Enable curl logging
dev?: boolean,
// Simulate browser CORS request
cors?: boolean,
curl?: Curl,
};
type CurlResponse={
url: string,
status: number,
dataRaw?: Buffer,
headers: HttpHeaders,
request: CurlRequestInfo,
options: RequestOptions,
// Request stack, including automatic redirect content
stacks: Array<CurlRequestInfo> = [],
index: number = 0,
redirects: number = 0,
curl: Curl,
jar:CookieJar,
// Text format of response content
text:string,
// If response is JSON, auto-parse, otherwise
data:any|string|Buffer,
}
// Use global interface to reuse connections and improve performance
const req1=new CurlSession({impl:gimpl})
This project is licensed under the MIT License - see the LICENSE file for details.
Inspired by curl_cffi
libcurl curl-impersonate