{"id":14222487,"url":"https://github.com/lexiforest/curl_cffi","last_synced_at":"2025-05-14T12:02:27.464Z","repository":{"id":57804534,"uuid":"468168223","full_name":"lexiforest/curl_cffi","owner":"lexiforest","description":"Python binding for curl-impersonate fork via cffi. A http client that can impersonate browser tls/ja3/http2 fingerprints.","archived":false,"fork":false,"pushed_at":"2025-05-06T00:42:17.000Z","size":1484,"stargazers_count":3562,"open_issues_count":58,"forks_count":334,"subscribers_count":36,"default_branch":"main","last_synced_at":"2025-05-07T11:41:50.276Z","etag":null,"topics":["akamai-fingerprint","curl","curl-impersonate","fingerprinting","http","http-client","http2-fingerprint","https","ja3","ja3-fingerprint","tls-fingerprint","web-scraping"],"latest_commit_sha":null,"homepage":"https://curl-cffi.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lexiforest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":"FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"lexiforest","buy_me_a_coffee":"yifei"}},"created_at":"2022-03-10T02:39:23.000Z","updated_at":"2025-05-07T10:36:28.000Z","dependencies_parsed_at":"2023-12-05T12:25:53.694Z","dependency_job_id":"f3e44147-6c58-4aa1-8f0a-fdc63016d17e","html_url":"https://github.com/lexiforest/curl_cffi","commit_stats":{"total_commits":316,"total_committers":31,"mean_commits":"10.193548387096774","dds":"0.23734177215189878","last_synced_commit":"fe117c2137fe5b0372b694c9376d41dff101bab0"},"previous_names":["lexiforest/curl_cffi","yifeikong/curl_cffi"],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexiforest%2Fcurl_cffi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexiforest%2Fcurl_cffi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexiforest%2Fcurl_cffi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexiforest%2Fcurl_cffi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lexiforest","download_url":"https://codeload.github.com/lexiforest/curl_cffi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140738,"owners_count":22021218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["akamai-fingerprint","curl","curl-impersonate","fingerprinting","http","http-client","http2-fingerprint","https","ja3","ja3-fingerprint","tls-fingerprint","web-scraping"],"created_at":"2024-08-19T19:01:46.557Z","updated_at":"2025-05-14T12:02:27.431Z","avatar_url":"https://github.com/lexiforest.png","language":"Python","funding_links":["https://github.com/sponsors/lexiforest","https://buymeacoffee.com/yifei"],"categories":["🥷 Stealth \u0026 Anti-Detection","Python"],"sub_categories":[],"readme":"# curl_cffi\n\n![PyPI - Downloads](https://img.shields.io/pypi/dm/curl-cffi)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/curl_cffi)\n[![PyPI version](https://badge.fury.io/py/curl-cffi.svg)](https://badge.fury.io/py/curl-cffi)\n[![Generic badge](https://img.shields.io/badge/Telegram%20Group-join-blue?logo=telegram)](https://t.me/+lL9n33eZp480MGM1)\n[![Generic badge](https://img.shields.io/badge/Discord-join-purple?logo=blue)](https://discord.gg/kJqMHHgdn2)\n\n[Documentation](https://curl-cffi.readthedocs.io)\n\nPython binding for [curl-impersonate fork](https://github.com/lexiforest/curl-impersonate)\nvia [cffi](https://cffi.readthedocs.io/en/latest/). For commercial support, visit [impersonate.pro](https://impersonate.pro).\n\nUnlike other pure python http clients like `httpx` or `requests`, `curl_cffi` can\nimpersonate browsers' TLS/JA3 and HTTP/2 fingerprints. If you are blocked by some\nwebsite for no obvious reason, you can give `curl_cffi` a try.\n\nPython 3.9 is the minimum supported version since v0.10.\n\n## Sponsors\n\nMaintenance of this project is made possible by all the \u003ca href=\"https://github.com/lexiforest/curl_cffi/graphs/contributors\"\u003econtributors\u003c/a\u003e and \u003ca href=\"https://github.com/sponsors/lexiforest\"\u003esponsors\u003c/a\u003e. If you'd like to sponsor this project and have your avatar or company logo appear below \u003ca href=\"https://github.com/sponsors/lexiforest\"\u003eclick here\u003c/a\u003e. 💖\n\n------\n\n\u003ca href=\"https://serpapi.com/\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/lexiforest/curl_cffi/main/assets/serpapi.png\" alt=\"SerpAPI\" height=\"67\" width=\"63\"\u003e\u003c/a\u003e\n\nScrape Google and other search engines from [SerpApi](https://serpapi.com/)'s fast, easy, and complete API. 0.66s average response time (≤ 0.5s for Ludicrous Speed Max accounts), 99.95% SLAs, pay for successful responses only.\n\n------\n\n### Bypass Cloudflare with API\n\n\u003ca href=\"https://yescaptcha.com/i/stfnIO\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/lexiforest/curl_cffi/main/assets/yescaptcha.png\" alt=\"Yes Captcha!\" height=\"47\" width=\"149\"\u003e\u003c/a\u003e\n\nYescaptcha is a proxy service that bypasses Cloudflare and uses the API interface to\nobtain verified cookies (e.g. `cf_clearance`). Click [here](https://yescaptcha.com/i/stfnIO)\nto register: https://yescaptcha.com/i/stfnIO\n\n------\n\n### Easy Captcha Bypass for Scraping\n\n\u003ca href=\"https://www.capsolver.com/?utm_source=github\u0026utm_medium=banner_repo\u0026utm_campaign=scraping\u0026utm_term=curl_cffi\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/lexiforest/curl_cffi/main/assets/capsolver.jpg\" alt=\"CapSolver\" height=\"50\" width=\"178\"\u003e\u003c/a\u003e\n\n[CapSolver](https://www.capsolver.com/?utm_source=github\u0026utm_medium=banner_repo\u0026utm_campaign=scraping\u0026utm_term=curl_cffi)\nis an AI-powered tool that easily bypasses Captchas, allowing uninterrupted access to\npublic data. It supports a variety of Captchas and works seamlessly with `curl_cffi`,\nPuppeteer, Playwright, and more. Fast, reliable, and cost-effective. Plus, `curl_cffi`\nusers can use the code **\"CURL\"** to get an extra 6% balance! and register [here](https://dashboard.capsolver.com/passport/?utm_source=github\u0026utm_medium=banner_repo\u0026utm_campaign=scraping\u0026utm_term=curl_cffi).\n\n------\n\n## Features\n\n- Supports JA3/TLS and http2 fingerprints impersonation, including recent browsers and custom fingerprints.\n- Much faster than requests/httpx, on par with aiohttp/pycurl, see [benchmarks](https://github.com/lexiforest/curl_cffi/tree/main/benchmark).\n- Mimics the requests API, no need to learn another one.\n- Pre-compiled, so you don't have to compile on your machine.\n- Supports `asyncio` with proxy rotation on each request.\n- Supports http 2.0 \u0026 3.0, which requests does not.\n- Supports websocket.\n\n||requests|aiohttp|httpx|pycurl|curl_cffi|\n|---|---|---|---|---|---|\n|http/2|❌|❌|✅|✅|✅|\n|http/3|❌|❌|❌|☑️\u003csup\u003e1\u003c/sup\u003e|☑️\u003csup\u003e2\u003c/sup\u003e|\n|sync|✅|❌|✅|✅|✅|\n|async|❌|✅|✅|❌|✅|\n|websocket|❌|✅|❌|❌|✅|\n|fingerprints|❌|❌|❌|❌|✅|\n|speed|🐇|🐇🐇|🐇|🐇🐇|🐇🐇|\n\nNotes:\n1. For pycurl, you need a http/3 enabled libcurl to make it work, while curl_cffi packages libcurl-impersonate inside Python wheels.\n2. Since v0.11.0. However, only Linux and macOS are supported, Windows is not supported due to failed building of ngtcp2.\n\n## Install\n\n    pip install curl_cffi --upgrade\n\nThis should work on Linux, macOS and Windows out of the box.\nIf it does not work on you platform, you may need to compile and install `curl-impersonate`\nfirst and set some environment variables like `LD_LIBRARY_PATH`.\n\nTo install beta releases:\n\n    pip install curl_cffi --upgrade --pre\n\nTo install unstable version from GitHub:\n\n    git clone https://github.com/lexiforest/curl_cffi/\n    cd curl_cffi\n    make preprocess\n    pip install .\n\nOn macOS, you may need to install the following dependencies:\n\n    brew install zstd nghttp2\n\n## Usage\n\n`curl_cffi` comes with a low-level `curl` API and a high-level `requests`-like API.\n\n### requests-like\n\nv0.9:\n\n```py\nfrom curl_cffi import requests\n\nr = requests.get(\"https://tls.browserleaks.com/json\", impersonate=\"chrome\")\n```\n\nv0.10:\n\n```python\nimport curl_cffi\n\n# Notice the impersonate parameter\nr = curl_cffi.get(\"https://tls.browserleaks.com/json\", impersonate=\"chrome\")\n\nprint(r.json())\n# output: {..., \"ja3n_hash\": \"aa56c057ad164ec4fdcb7a5a283be9fc\", ...}\n# the js3n fingerprint should be the same as target browser\n\n# To keep using the latest browser version as `curl_cffi` updates,\n# simply set impersonate=\"chrome\" without specifying a version.\n# Other similar values are: \"safari\" and \"safari_ios\"\nr = curl_cffi.get(\"https://tls.browserleaks.com/json\", impersonate=\"chrome\")\n\n# Randomly choose a browser version based on current market share in real world\n# from: https://caniuse.com/usage-table\n# NOTE: this is a pro feature.\nr = curl_cffi.get(\"https://example.com\", impersonate=\"realworld\")\n\n# To pin a specific version, use version numbers together.\nr = curl_cffi.get(\"https://tls.browserleaks.com/json\", impersonate=\"chrome124\")\n\n# To impersonate other than browsers, bring your own ja3/akamai strings\n# See examples directory for details.\nr = curl_cffi.get(\"https://tls.browserleaks.com/json\", ja3=..., akamai=...)\n\n# http/socks proxies are supported\nproxies = {\"https\": \"http://localhost:3128\"}\nr = curl_cffi.get(\"https://tls.browserleaks.com/json\", impersonate=\"chrome\", proxies=proxies)\n\nproxies = {\"https\": \"socks://localhost:3128\"}\nr = curl_cffi.get(\"https://tls.browserleaks.com/json\", impersonate=\"chrome\", proxies=proxies)\n```\n\n### Sessions\n\nv0.9:\n\n```py\nfrom curl_cffi import requests\n\ns = requests.Session()\n```\n\nv0.10:\n\n```python\ns = curl_cffi.Session()\n\n# httpbin is a http test website, this endpoint makes the server set cookies\ns.get(\"https://httpbin.org/cookies/set/foo/bar\")\nprint(s.cookies)\n# \u003cCookies[\u003cCookie foo=bar for httpbin.org /\u003e]\u003e\n\n# retrieve cookies again to verify\nr = s.get(\"https://httpbin.org/cookies\")\nprint(r.json())\n# {'cookies': {'foo': 'bar'}}\n```\n\n### Supported impersonate browsers\n\n`curl_cffi` supports the same browser versions as supported by my [fork](https://github.com/lexiforest/curl-impersonate) of [curl-impersonate](https://github.com/lwthiker/curl-impersonate):\n\nOpen source version of curl_cffi includes versions whose fingerprints differ from previous versions.\nIf you see a version, e.g. `chrome135`, were skipped, you can simply impersonate it with your own headers and the previous version.\n\nIf you don't want to look up the headers etc, by yourself, consider buying commercial support from [impersonate.pro](https://impersonate.pro),\nwe have comprehensive browser fingerprints database for almost all the browser versions on various platforms.\n\nIf you are trying to impersonate a target other than a browser, use `ja3=...` and `akamai=...`\nto specify your own customized fingerprints. See the [docs on impersonation](https://curl-cffi.readthedocs.io/en/latest/impersonate.html) for details.\n\n|Browser|Open Source| Pro version|\n|---|---|---|\n|Chrome|chrome99, chrome100, chrome101, chrome104, chrome107, chrome110, chrome116\u003csup\u003e[1]\u003c/sup\u003e, chrome119\u003csup\u003e[1]\u003c/sup\u003e, chrome120\u003csup\u003e[1]\u003c/sup\u003e, chrome123\u003csup\u003e[3]\u003c/sup\u003e, chrome124\u003csup\u003e[3]\u003c/sup\u003e, chrome131\u003csup\u003e[4]\u003c/sup\u003e, chrome133a\u003csup\u003e[5][6]\u003c/sup\u003e, chrome136\u003csup\u003e[6]\u003c/sup\u003e|chrome132, chrome134, chrome135|\n|Chrome Android| chrome99_android, chrome131_android \u003csup\u003e[4]\u003c/sup\u003e|chrome132_android, chrome133_android, chrome134_android, chrome135_android|\n|Chrome iOS|N/A|coming soon|\n|Safari \u003csup\u003e[7]\u003c/sup\u003e|safari15_3 \u003csup\u003e[2]\u003c/sup\u003e, safari15_5 \u003csup\u003e[2]\u003c/sup\u003e, safari17_0 \u003csup\u003e[1]\u003c/sup\u003e, safari18_0 \u003csup\u003e[4]\u003c/sup\u003e, safari18_4 \u003csup\u003e[6]\u003c/sup\u003e|coming soon|\n|Safari iOS \u003csup\u003e[7]\u003c/sup\u003e| safari17_2_ios\u003csup\u003e[1]\u003c/sup\u003e, safari18_0_ios\u003csup\u003e[4]\u003c/sup\u003e, safari18_4_ios \u003csup\u003e[6]\u003c/sup\u003e|coming soon|\n|Firefox|firefox133\u003csup\u003e[5]\u003c/sup\u003e, firefox135\u003csup\u003e[7]\u003c/sup\u003e|coming soon|\n|Firefox Android|N/A|firefox135_android|\n|Tor|tor145 \u003csup\u003e[7]\u003c/sup\u003e|coming soon|\n|Edge|edge99, edge101|edge133, edge135|\n|Opera|N/A|coming soon|\n|Brave|N/A|coming soon|\n\n\nNotes:\n1. Added in version `0.6.0`.\n2. Fixed in version `0.6.0`, previous http2 fingerprints were [not correct](https://github.com/lwthiker/curl-impersonate/issues/215).\n3. Added in version `0.7.0`.\n4. Added in version `0.8.0`.\n5. Added in version `0.9.0`.\n6. The version postfix `-a`(e.g. `chrome133a`) means that this is an alternative version, i.e. the fingerprint has not been officially updated by browser, but has been observed because of A/B testing.\n5. Added in version `0.10.0`.\n6. Added in version `0.11.0`.\n7. Since `0.11.0`, the format `safari184_ios` is preferred over `safari18_4_ios`, both are supported, but the latter is quite confusing and hard to parse.\n\n### Asyncio\n\n```python\nfrom curl_cffi import AsyncSession\n\nasync with AsyncSession() as s:\n    r = await s.get(\"https://example.com\")\n```\n\nMore concurrency:\n\n```python\nimport asyncio\nfrom curl_cffi import AsyncSession\n\nurls = [\n    \"https://google.com/\",\n    \"https://facebook.com/\",\n    \"https://twitter.com/\",\n]\n\nasync with AsyncSession() as s:\n    tasks = []\n    for url in urls:\n        task = s.get(url)\n        tasks.append(task)\n    results = await asyncio.gather(*tasks)\n```\n\n### WebSockets\n\n```python\nfrom curl_cffi import WebSocket\n\ndef on_message(ws: WebSocket, message: str | bytes):\n    print(message)\n\nws = WebSocket(on_message=on_message)\nws.run_forever(\"wss://api.gemini.com/v1/marketdata/BTCUSD\")\n```\n\nFor low-level APIs, Scrapy integration and other advanced topics, see the\n[docs](https://curl-cffi.readthedocs.io) for more details.\n\n### Asyncio WebSockets\n\n```python\nimport asyncio\nfrom curl_cffi import AsyncSession\n\nasync with AsyncSession() as s:\n    ws = await s.ws_connect(\"wss://echo.websocket.org\")\n    await asyncio.gather(*[ws.send_str(\"Hello, World!\") for _ in range(10)])\n    async for message in ws:\n        print(message)\n```\n\n## Ecosystem\n\n- Integrating with Scrapy: [jxlil/scrapy-impersonate](https://github.com/jxlil/scrapy-impersonate) and [tieyongjie/scrapy-fingerprint](https://github.com/tieyongjie/scrapy-fingerprint).\n- Integrating with [requests](https://github.com/el1s7/curl-adapter), [httpx](https://github.com/vgavro/httpx-curl-cffi) as adapter.\n- Integrating with captcha resolvers: [CapSolver](https://docs.capsolver.com/en/api/), [YesCaptcha](https://yescaptcha.atlassian.net/wiki/spaces/YESCAPTCHA/overview). Please see the head area for promo code and link.\n\n## Acknowledgement\n\n- Originally forked from [multippt/python_curl_cffi](https://github.com/multippt/python_curl_cffi), which is under the MIT license.\n- Headers/Cookies files are copied from [httpx](https://github.com/encode/httpx/blob/master/httpx/_models.py), which is under the BSD license.\n- Asyncio support is inspired by Tornado's curl http client.\n- The synchronous WebSocket API is inspired by [websocket_client](https://github.com/websocket-client/websocket-client).\n- The asynchronous WebSocket API is inspired by [aiohttp](https://github.com/aio-libs/aiohttp).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexiforest%2Fcurl_cffi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flexiforest%2Fcurl_cffi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexiforest%2Fcurl_cffi/lists"}