Skip to main content

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

Project description

rqsession

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  # routes through a local Rust proxy process

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.2.tar.gz (275.5 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.2-cp314-cp314-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.14Windows x86-64

rqsession-0.4.2-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.2-cp313-cp313-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.13Windows x86-64

rqsession-0.4.2-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.2-cp312-cp312-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.12Windows x86-64

rqsession-0.4.2-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.2-cp311-cp311-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.11Windows x86-64

rqsession-0.4.2-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.2-cp310-cp310-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.10Windows x86-64

rqsession-0.4.2-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.2-cp39-cp39-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

rqsession-0.4.2-cp38-cp38-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rqsession-0.4.2.tar.gz
Algorithm Hash digest
SHA256 6bec01c449006a5bf391063e01d471d9917229768016ff896f602903f827c43c
MD5 edb125cdfe38dcf8b75b9e78d5ea31c5
BLAKE2b-256 b783d7d3d8d8530093fbb22f84a194a94dc6e283544c82c0830d7f18beccdf99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 43a80e1de4da1585a836330de80a8e2622ee52dc9929351bedc851df231cdd88
MD5 715351c79f8d00d4855e8791e5adfcfb
BLAKE2b-256 e869ce011f79090a8aee95377685cc4d926091e4d82b082b05df9d64ea3816f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7893fb3765bca031861820b7c4dafeb38cedbc51f97cf41eb4369267e47e4e0c
MD5 186fd1168f856b2ccb50485f60ec4c6d
BLAKE2b-256 17f50b543e9f2ebe2351095beb4188706dcc9a33db73566a9f6b0be13023dda3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ab78d1fe0a64d1a730572589b3c9b1328adcc69d4d05e51ee223a7a6f62769bf
MD5 ff6379fb6cc1c9ed8f51aa4668ba7dba
BLAKE2b-256 77845a38330259f1abb28382c83ba185c4d7816d8a8a46a33fc30a5900e09e39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b56e60d4dc01f4dfe707ae4e7853382e7306bf962c68294638999a078142d627
MD5 6b6291d0eb04aced2557c7fe9a6c8939
BLAKE2b-256 16e1cbacf85a975bf8b5d61108c3c08fdecf31275c623f3a9bbbf136cbae5a85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a4f368951e7fdf4296c4b925f68828a5647a92734fab2f1ab46844ffeda1fdf0
MD5 0ce2e2ebdf3a15958a52aebcede6e2b2
BLAKE2b-256 59fee72314f14746ee8298f2207e24702ee85c5b38fb2ad96366f0ecea8da024

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3970b7d2c7dc30c8998f26a20ed15df0c70f30f8d9d5f12ee749c83d25c99208
MD5 f9be8658e0e4431ad1b51d4868853a03
BLAKE2b-256 09da536b847fdec61c8ffeb4fa10d23e6f11c070351e9a9add8b2e2a334058e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2fe0de6828aad8d800d13b443eef8c7eeb83cf3cb1a1adc94de0fe7e7ba1b877
MD5 b7449e3e995a0c0f62a67b281de78fc1
BLAKE2b-256 10ffb0bdfa66a6415a542d32414805007fe246bbe4cf0f4be290c91f76504c8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d8941fdcf443b0a9d89ead18fff57c6d79917bc4f13a2d1de2e43274a7cbe069
MD5 d8e58c525069efa3f79eb4f6cf898ea0
BLAKE2b-256 ca1ce6526fb59509b65b153625b3811a22b54ca0fbb6b1ac9aaa504010c61a1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 666d40cc5abc00c23688eb7c4cee4fc7df5c762c84281ff238716c9156116601
MD5 edd6da15b784e1d4795607b422d8bbbc
BLAKE2b-256 69194438758af3976f15d54c4c71f3e6b21a96e3a04f51ce03497c9ce9dbb601

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1af6687e3fc732e7d84b0376e464d970bbb49a63c04d7b0b8459a0956288e2b3
MD5 6dc0e18309200d4d7a183ca3507e0af7
BLAKE2b-256 784c002155b6b1569ef37e5d4fb5b96d49ba3471b9b50084fc31913140a3cfdb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rqsession-0.4.2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e34a3bd460ce5366338ffcf6b8777407ce938094e2d71833f1094f89493b443
MD5 4db5494b3de823e81df6e4a84e9cfa55
BLAKE2b-256 f6fbd0951fbc9d51392b14a246fafeee687d068aa6b235d332319e2da115b95a

See more details on using hashes here.

File details

Details for the file rqsession-0.4.2-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rqsession-0.4.2-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b88548d05c8d3cc8ed5b1636fc3b59daee8d5775133b04ffcb1ad0b80be86872
MD5 2411e987faed8321f3deaacbca2294cc
BLAKE2b-256 d5391a92451fbb551ceacf938febd008d7fff231d8f920ec9858e6a5a6c22a15

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