Skip to main content

Browser TLS fingerprint impersonation library powered by Rust (BoringSSL + hyper).

Project description

rqsession

中文 | English

A Python HTTP library that impersonates real browser TLS fingerprints, powered by a Rust native extension (BoringSSL + hyper + tokio).

PyPI version Python versions License


What it does

Most anti-bot systems (Cloudflare, Akamai, DataDome, etc.) inspect the TLS ClientHello and HTTP/2 SETTINGS frame to distinguish scrapers from real browsers. Standard requests or httpx produce a recognizable Python fingerprint regardless of what User-Agent you set.

rqsession controls the full fingerprint stack at the Rust level:

Layer What is controlled
TLS ClientHello Cipher suite order, supported groups (curves), ALPN, signature algorithms, version range
HTTP/2 SETTINGS frame values (window size, max frame size), connection WINDOW_UPDATE
HTTP headers Exact header order, browser-specific headers (sec-ch-ua, sec-fetch-*, etc.)

No external proxy process required — it's a compiled .pyd / .so extension, imported directly.


Installation

pip install rqsession

Pre-built wheels are available for Windows x86_64 and Linux x86_64 (Python 3.9+).
Other platforms require a local Rust toolchain to build from the source distribution.


Quick Start

Synchronous

from rqsession.rust_session import BrowserSession, Chrome120

with BrowserSession(Chrome120) as s:
    resp = s.get("https://httpbin.org/get")
    print(resp.status_code)   # 200
    print(resp.json())

Async

import asyncio
from rqsession.rust_session import AsyncBrowserSession, Chrome120

async def main():
    async with AsyncBrowserSession(Chrome120) as s:
        resp = await s.get("https://httpbin.org/get")
        print(resp.status_code)
        print(resp.json())

asyncio.run(main())

Concurrent async requests

import asyncio
from rqsession.rust_session import AsyncBrowserSession, Chrome120

async def main():
    async with AsyncBrowserSession(Chrome120) as s:
        results = await asyncio.gather(
            s.get("https://httpbin.org/get"),
            s.get("https://httpbin.org/ip"),
            s.get("https://httpbin.org/user-agent"),
        )
    for r in results:
        print(r.status_code)

asyncio.run(main())

Built-in Browser Profiles

Import name Browser OS
Chrome138 Chrome 138 Windows
Chrome120 Chrome 120 Windows
Chrome119 Chrome 119 Windows
Edge147 Edge 147 Windows
Edge142 Edge 142 Windows
Edge141 Edge 141 Windows
Firefox146 Firefox 146 Windows
Firefox133 Firefox 133 Windows
Tor128 Tor Browser 128 Windows
Safari17 Safari 17 macOS
MacosChrome140 Chrome 140 macOS
AndroidChrome114 Chrome 114 Android
Py37Aiohttp381 Python aiohttp 3.8.1 Windows
from rqsession.rust_session import (
    BrowserSession, AsyncBrowserSession,
    Chrome138, Chrome120, Chrome119,
    Edge147, Edge142, Edge141,
    Firefox146, Firefox133,
    Tor128, Safari17, MacosChrome140,
    AndroidChrome114, Py37Aiohttp381,
)

Each profile carries its own cipher suite order, curves, signature algorithms, HTTP/2 settings, and header order — matching the real browser's wire behavior.


Proxy Support

Both sync and async sessions accept a proxy URL at construction time:

# HTTP proxy
s = BrowserSession(Chrome120, proxy="http://127.0.0.1:7890")

# Authenticated proxy
s = BrowserSession(Chrome120, proxy="http://user:pass@host:port")

# Async
async with AsyncBrowserSession(Firefox133, proxy="http://127.0.0.1:7890") as s:
    resp = await s.get("https://example.com")

The proxy tunnel is implemented as an HTTP CONNECT connection at the TCP level, so TLS fingerprinting applies end-to-end through the tunnel.


Session API

Constructor parameters

BrowserSession(
    profile,              # built-in constant or BrowserProfile object
    *,
    proxy=None,           # "http://[user:pass@]host:port"
    verify=True,          # set False to skip SSL verification
    ca_bundle=None,       # path to CA bundle; auto-detects certifi when None
)
# AsyncBrowserSession takes the same parameters

Request methods

# GET
resp = s.get(url, headers={...}, params={...})

# POST — form data or JSON
resp = s.post(url, data=b"...", headers={...})
resp = s.post(url, json={"key": "value"})

# Generic
resp = s.request("PUT", url, headers={...}, json={...})

# Async versions — same signature, add `await`
resp = await s.get(url)
resp = await s.post(url, json={...})

Response object

Compatible with requests.Response style:

resp.status_code    # int
resp.text           # str (auto-decoded)
resp.content        # bytes
resp.headers        # dict[str, str]
resp.json()         # parsed JSON → dict / list
resp.ok             # True when status < 400
resp.raise_for_status()   # raises on 4xx/5xx
resp.url            # final URL after redirects

Response bodies are automatically decompressed (gzip, deflate, br, zstd).

Cookies

# Persist cookies manually
s.update_cookies({"token": "abc123"})

# Cookies from Set-Cookie response headers are automatically
# stored in the session and sent on subsequent requests.

Adding Custom Browser Profiles

Capture a fingerprint from a real browser using tls.peet.ws/api/all, then convert it:

# Save output from tls.peet.ws as chrome136.json, then:
python tools/tls_peet_to_profile.py chrome136.json -n chrome136_windows --install

The --install flag writes the profile directly to rqsession/rust_session/profiles/builtin/.
You can also load profiles at runtime without rebuilding:

from rqsession.rust_session import BrowserSession, load_custom, load_profile_json
from rqsession._rust_core import load_profile

# From profiles/custom/<name>.json
s = BrowserSession(load_custom("my_browser"))

# From a JSON string
s = BrowserSession(load_profile_json('{"name": "...", "tls": {...}, ...}'))

# From an arbitrary file path
s = BrowserSession(load_profile("/path/to/profile.json"))

# List available profiles
from rqsession.rust_session import list_builtin, list_custom
print(list_builtin())   # ['chrome120_windows', 'firefox133_windows', ...]
print(list_custom())    # ['my_browser', ...]

Windows asyncio note

Python 3.8+ on Windows uses ProactorEventLoop by default. If you see event-loop errors, switch to SelectorEventLoop before asyncio.run():

import asyncio, sys

if sys.platform == "win32":
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

asyncio.run(main())

Legacy layers

Earlier versions of this library included RequestSession and EnhancedRequestSession. These layers are still available for backward compatibility:

from rqsession import RequestSession          # basic requests.Session wrapper
from rqsession import EnhancedRequestSession  # requests.Session wrapper with browser headers

For new projects, use BrowserSession / AsyncBrowserSession instead — they are faster, require no external process, and provide more accurate fingerprinting.


License

Apache 2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rqsession-0.4.3.tar.gz (275.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rqsession-0.4.3-cp314-cp314-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.14Windows x86-64

rqsession-0.4.3-cp314-cp314-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

rqsession-0.4.3-cp313-cp313-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.13Windows x86-64

rqsession-0.4.3-cp313-cp313-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

rqsession-0.4.3-cp312-cp312-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.12Windows x86-64

rqsession-0.4.3-cp312-cp312-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

rqsession-0.4.3-cp311-cp311-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.11Windows x86-64

rqsession-0.4.3-cp311-cp311-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

rqsession-0.4.3-cp310-cp310-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.10Windows x86-64

rqsession-0.4.3-cp310-cp310-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

rqsession-0.4.3-cp39-cp39-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

File details

Details for the file rqsession-0.4.3.tar.gz.

File metadata

  • Download URL: rqsession-0.4.3.tar.gz
  • Upload date:
  • Size: 275.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for rqsession-0.4.3.tar.gz
Algorithm Hash digest
SHA256 90f89b063dcbd9b43b66f4097b54013611d5d08b0429ff8d97432bfe1d7323f8
MD5 6871512e87bd61cf14e038bc3461f0fb
BLAKE2b-256 bbe056453b8d63dfe08a78f59105013d655b141ed92bebd72d7fb2871cd7a75d

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 bc3099fe5ef725786a1b83cf2a60a1f47630fe3a8d07cca5643ab96c2e392c9e
MD5 57c73dfa3b51c0b9c6ab1b0696db21fa
BLAKE2b-256 65752981bd9bfd5b2d662cc1a9ab44ef6bdca2967ec7895e76a65c4e7cb25dd7

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f114fd4e668fe44a0e9764bf5a0e21e4dad9bd602dbd1ca685e4b6539fd868af
MD5 e0c1282424a93fe4c87666fd8b52531c
BLAKE2b-256 2a35b9935f93511a5823b35f0fa2394cd8066e0ea410dece201a69f5af4dfef8

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 709f8a7efedc35b476f31fcbe05f3a5674f0db6cd838b3f508e0c27fb01dc966
MD5 f1a301bfef8036d1ff61d3ea7afb6335
BLAKE2b-256 027536552a78048fbf049dedaea0f2ee3c564762216dd4ef3ac7cf02bb4daf9b

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 37d19af11c6c0ff9867d99411da596919fbc4cca15657aa692015a18597a5631
MD5 49723cc29bff82e3e97c31e8002bcc67
BLAKE2b-256 ad9cdeb7ac2142641cfc6355d41788d90b929ae996154ddb3f9e3caf19c8a31c

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9e7a354da7f9bac250e0cb78233f648d0b8d34cfe020a0c2bb6f4118ead3f84b
MD5 4e3724ec5aec1fdd0752bc13a32bcb7c
BLAKE2b-256 ea4508414bf001111dd9cbc0fe5aa222078ca87338ec036c5b11be3a4f9ec6eb

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4c01ae2293cb06a127798c0e213f2e84ece64bda35c0f29e3115b7f82c3e2789
MD5 6614308730161446d0adcd8e8dbcb202
BLAKE2b-256 a2e61e305fa4ee11ec2ecf9572528158997ac098a750fa9fd35eee1e2c27e114

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b3f5dd22601289d4c5f62baa7250e2e781a4e42140bcb8571a1f32905a8ae5dc
MD5 1c7ce41486a7c1c1a17618cccf9fa4dc
BLAKE2b-256 2b9e8c964bcf95223c7fe18c738107180a259f7c469c50a301fc1b33e6693761

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3b846be3d1b8ea077e29ad146462d16ceffd298d61ab4f53193fcba32df1545c
MD5 3fcc80b0362a865e3a5fc28b41317004
BLAKE2b-256 d9f1b8c17c22035ad0f6d9c04e15c66166555d40eb6c90d16dd6ae453b7eb327

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 32c79cf6481561a6fb486bc57b3bb0ce0b02adaa86748b35b45798e84a1ba51f
MD5 fc8cba904e4ff338168fd3b3a1ad20a2
BLAKE2b-256 cd9d809eafaa468ac444a6616dd6afefd42f4706519f91b5faf16fa3457af266

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2a8e094760ad4a08e648ea39e759ec04dd5cd6bde295878cfbafbc2a72ff22be
MD5 4b0f72857873147fe8eba84bd234d100
BLAKE2b-256 7d8ce5e9abe8c6acf777803408013000e2ad540119a911aad2a65ec07ed85d42

See more details on using hashes here.

File details

Details for the file rqsession-0.4.3-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.3-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7c10d1c9f4ccb28dcb36bd27e642060a593340a75574af691635c014b324e47d
MD5 95b371174a88219b401b9ff9c80e43cc
BLAKE2b-256 d02c36af35033bda52f652ecf5867738f21df2ca8c832cf928b9698b2234a70b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page