Skip to main content

High-performance Python binding for bogdanfinn/tls-client via CFFI – zero-copy, panic-proof, full TLS fingerprint control

Project description

tls-client-python

PyPI version Python License: MIT

High-performance Python binding for bogdanfinn/tls-client via CFFI.


What is TLS Fingerprinting?

Some people think it is enough to change the user-agent header of a request to let the server think that the client requesting a resource is a specific browser. Nowadays this is not enough, because the server might use a technique to detect the client browser which is called TLS Fingerprinting.

For a deep dive, see this excellent article on TLS fingerprinting.

✨ Features

Category Details
🔐 TLS Fingerprinting Impersonate Chrome, Firefox, Safari, Brave, Opera, OkHttp & more
🌐 Protocol Support HTTP/1.1, HTTP/2 (h2), HTTP/3 (QUIC) with automatic negotiation
Protocol Racing Chrome-style Happy Eyeballs for HTTP/2 vs HTTP/3
📋 Header Ordering Control the exact order of HTTP headers per request
🔒 Certificate Pinning Pin server certificates for enhanced security
🍪 Cookie Jar Built-in cookie handling with customisable jar
🚇 Proxy Support HTTP and SOCKS5 proxies with CONNECT auth
🔀 Redirect Control Choose whether to follow redirects per request
📊 Bandwidth Tracking Monitor upload/download bytes in real time
🔄 sync/Async Session + AsyncSession
🛡️ Panic-proof All Go panics caught and surfaced as Python exceptions
⚙️ Custom TLS Full 26-field custom TLS client configuration

📦 Installation

pip install tls-client-python

Pre-compiled binaries are included for 9 platforms — no Go toolchain required.

Requirements: Python 3.6+


🚀 Quick Start

from tls_client import Session

# Create a session with Chrome 146 fingerprint
session = Session(client_identifier="chrome_146", verify=False)

# GET request
resp = session.get("https://tls.browserleaks.com/json")
print(resp.status_code)
print(resp.text)

# POST request
resp = session.post("https://tools.scrapfly.io/api/fp/ja3")
data = resp.json()
print(resp.status_code)
print(data)


# Context Manager
with Session(client_identifier="firefox_148") as session:
    resp = session.get("https://tls.browserleaks.com/json")
    print(resp.status_code)
    print(resp.text)


# Async Usage
import asyncio
from tls_client import AsyncSession

async def main():
    async with AsyncSession(client_identifier="firefox_148") as s:
        resp = await s.get("https://tls.browserleaks.com/json")
        print(resp.status_code)
        print(resp.json())

asyncio.run(main())

🖥️ Supported Platforms

Pre-compiled native libraries are bundled for these platforms:

OS Architecture Binary
Windows x86-64 tls-client-windows-amd64.dll
Windows x86 (32-bit) tls-client-windows-386.dll
macOS x86-64 tls-client-darwin-amd64.dylib
macOS ARM64 (Apple Silicon) tls-client-darwin-arm64.dylib
Linux x86-64 (glibc) tls-client-linux-amd64.so
Linux x86 (32-bit, glibc) tls-client-linux-386.so
Linux ARM64 tls-client-linux-arm64.so
Linux ARMv7 tls-client-linux-arm.so
Alpine Linux x86-64 (musl) tls-client-alpine-amd64.so

The correct binary is automatically selected at runtime. Override via TLS_CLIENT_LIB environment variable.


🎭 Supported Browser Profiles — 79 Identifiers

🌐 Chrome — 24 Profiles

Identifier Notes
chrome_103chrome_112 Chrome Stable 103–112
chrome_116_PSK Chrome 116 with PSK key exchange
chrome_116_PSK_PQ Chrome 116 with PSK + Post-Quantum
chrome_117 Chrome 117
chrome_120 Chrome 120
chrome_124 Chrome 124
chrome_130_PSK Chrome 130 with PSK
chrome_131 · chrome_131_PSK Chrome 131 (standard & PSK)
chrome_133 · chrome_133_PSK Chrome 133 (standard & PSK)
chrome_144 · chrome_144_PSK Chrome 144 (standard & PSK)
chrome_146 · chrome_146_PSK Chrome 146 — default (standard & PSK)

🦊 Firefox — 16 Profiles

Identifier Notes
firefox_102 · firefox_104 · firefox_105 · firefox_106 Firefox 102–106
firefox_108 · firefox_110 Firefox 108 · 110
firefox_117 · firefox_120 · firefox_123 Firefox 117–123
firefox_132 · firefox_133 · firefox_135 Firefox 132–135
firefox_146_PSK Firefox 146 with PSK
firefox_147 · firefox_147_PSK Firefox 147 (standard & PSK)
firefox_148 Firefox 148

🍏 Safari — 10 Profiles

Identifier Device
safari_15_6_1 Safari 15.6.1 (macOS)
safari_16_0 Safari 16.0 (macOS)
safari_ipad_15_6 Safari 15.6 (iPadOS)
safari_ios_15_5 · safari_ios_15_6 Safari iOS 15.5–15.6
safari_ios_16_0 · safari_ios_17_0 Safari iOS 16 · 17
safari_ios_18_0 · safari_ios_18_5 Safari iOS 18 · 18.5
safari_ios_26_0 Safari iOS 26

🦁 Brave — 2 Profiles

Identifier Notes
brave_146 Brave Browser 146
brave_146_PSK Brave 146 with PSK

🎭 Opera — 3 Profiles

Identifier
opera_89 · opera_90 · opera_91

🤖 OkHttp (Android) — 7 Profiles

Identifier
okhttp4_android_7okhttp4_android_13

📱 Mobile / App SDKs — 16 Profiles

Category Identifiers
Zalando zalando_android_mobile · zalando_ios_mobile
Nike nike_ios_mobile · nike_android_mobile
MMS mms_ios · mms_ios_1 · mms_ios_2 · mms_ios_3
Mesh mesh_ios · mesh_ios_1 · mesh_ios_2 · mesh_android · mesh_android_1 · mesh_android_2
Confirmed confirmed_ios · confirmed_android

☁️ Cloudflare-specific — 1 Profile

Identifier Notes
cloudscraper Custom profile tuned for Cloudflare-protected sites

🔧 Advanced Usage

Custom TLS Client (Full Control)

Set custom_tls_client with up to 26 fields to bypass client_identifier entirely:

session = Session(custom_tls_client={
    "ja3_string": "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
    "h2_settings": {"HEADER_TABLE_SIZE": 65536, "MAX_CONCURRENT_STREAMS": 1000},
    "h2_settings_order": ["HEADER_TABLE_SIZE", "MAX_CONCURRENT_STREAMS"],
    "pseudo_header_order": [":method", ":authority", ":scheme", ":path"],
    "connection_flow": 1048576,
    "key_share_curves": ["X25519", "P256"],
    "alpn_protocols": ["h2", "http/1.1"],
    "supported_versions": ["1.3", "1.2"],
    "stream_id": 3,
})

Certificate Pinning

session = Session(
    certificate_pinning_hosts={
        "example.com": ["sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="]
    }
)

Client Certificates (mTLS)

session = Session(
    client_certificates=[{
        "cert_pem": open("client.crt", "rb").read(),
        "key_pem": open("client.key", "rb").read(),
    }]
)

Stream Response to Disk

resp = session.stream_to_file(
    "GET", "https://tls.browserleaks.com/",
    output_path="/tmp/image.png"
)
print(resp.status_code)  # response metadata still available

Per-Request Overrides

All Session constructor parameters can be overridden per request:

s = Session(client_identifier="chrome_146")
# Override fingerprint for a single request
resp = s.get("https://tls.browserleaks.com/json", client_identifier="firefox_148")

🔬 Architecture

Layer Technology
Go Engine bogdanfinn/tls-client compiled as C shared library (-buildmode=c-shared)
FFI Boundary Raw C structs via CFFI — no JSON serialization overhead
Memory Safety ffi.gc(resp, FreeResponse) — Go panics surfaced as RuntimeError
Python API requests-style Session, Response, AsyncSession

📚 API Reference

Session

Method Description
get(url, **kwargs) HTTP GET
post(url, **kwargs) HTTP POST
put(url, **kwargs) HTTP PUT
delete(url, **kwargs) HTTP DELETE
head(url, **kwargs) HTTP HEAD
patch(url, **kwargs) HTTP PATCH
execute_request(method, url, **kwargs) Generic request with full options
typed_request(Request) Strongly-typed request
stream_to_file(method, url, path) Stream response body to disk
clear_client_pool() Close idle connections (static)

Response

Property / Method Description
status_code HTTP status code (int)
headers Response headers (dict of list)
content Raw bytes body
text Decoded text body
encoding Detected charset
url Final URL after redirects
cookies Response cookies dict
used_protocol Protocol used (e.g. HTTP/2.0)
ok True if status_code < 400
reason HTTP reason phrase
json() Parse body as JSON
raise_for_status() Raise RuntimeError on 4xx/5xx

🔗 Credits

This project is a Python binding for bogdanfinn/tls-client, which itself is built upon:


📄 License

MIT — see LICENSE.


🙏 Community

Join the Discord server for support and discussion.


Powered by
JetBrains logo.

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

tls_client_python-1.15.1.1.tar.gz (23.7 MB view details)

Uploaded Source

Built Distributions

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

tls_client_python-1.15.1.1-py3-none-win_amd64.whl (23.8 MB view details)

Uploaded Python 3Windows x86-64

tls_client_python-1.15.1.1-py3-none-win32.whl (23.8 MB view details)

Uploaded Python 3Windows x86

tls_client_python-1.15.1.1-py3-none-musllinux_1_1_x86_64.whl (23.8 MB view details)

Uploaded Python 3musllinux: musl 1.1+ x86-64

tls_client_python-1.15.1.1-py3-none-macosx_11_0_arm64.whl (23.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

tls_client_python-1.15.1.1-py3-none-macosx_10_9_x86_64.whl (23.8 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file tls_client_python-1.15.1.1.tar.gz.

File metadata

  • Download URL: tls_client_python-1.15.1.1.tar.gz
  • Upload date:
  • Size: 23.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tls_client_python-1.15.1.1.tar.gz
Algorithm Hash digest
SHA256 756a18034db8fb0854ad64da69806fbefc77bdbbf3efb3f4c1022d0503146876
MD5 a75675347af9922a8cd1e81eabf57df8
BLAKE2b-256 d6f6adba9be6ad2b700799ec0a5220bf4e155e3a22c264ec4841759d7fd0c0d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1.tar.gz:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tls_client_python-1.15.1.1-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for tls_client_python-1.15.1.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 ae5491ec11c9d92eb29da3a1fdf354b2cfe4b8e3c7fa403de776cd75b4e91e5a
MD5 c409141ff05713d74b6a1b5185fa1b8a
BLAKE2b-256 f40b724ae20cb967c5b67715ccce2c41fd974a3b22d483ea18b04a39a5330b5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1-py3-none-win_amd64.whl:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tls_client_python-1.15.1.1-py3-none-win32.whl.

File metadata

File hashes

Hashes for tls_client_python-1.15.1.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 282867b66a193ba885d89f0ca47d4d535edd39d869da6189e9d12fe42d2461ed
MD5 634bd04f9033160c3ee9abe18bcd670a
BLAKE2b-256 efa7764d2c21f87b56f95704085077e37cc42a6b908ca34577a0f295c7addd41

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1-py3-none-win32.whl:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tls_client_python-1.15.1.1-py3-none-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for tls_client_python-1.15.1.1-py3-none-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ffdee219f82547989c420b2210fc77f574d4d19f7cf6c177297fc09cd578da59
MD5 5c9f08f4bda09957490b3618fb97cc48
BLAKE2b-256 e132952848ace2a99b12b6c055e6535224443d7b4118b73c3811c58150a15c67

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1-py3-none-musllinux_1_1_x86_64.whl:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tls_client_python-1.15.1.1-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tls_client_python-1.15.1.1-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c8454ef0a1b2e6bbc8f8ae079b44b65f9a8316779b2381a7e64d401f75b42a61
MD5 ce595752be8a3b6c5bab13db86a844d2
BLAKE2b-256 a388df503ea7ede2049368b014dbc45693945233c6e1b66b1c1157b308bef0bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1-py3-none-manylinux2014_x86_64.whl:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tls_client_python-1.15.1.1-py3-none-manylinux2014_i686.whl.

File metadata

File hashes

Hashes for tls_client_python-1.15.1.1-py3-none-manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7aecefaca9cbf46f176b0af1c6458641f37ad950b2b492c81a650432196b8458
MD5 5ae4f9fb489380962055e4e07285b703
BLAKE2b-256 53493c7f5aaf5c7c26bbed84ba3c10ad8fd44bf72004556fc7c96a25ff2aa0ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1-py3-none-manylinux2014_i686.whl:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tls_client_python-1.15.1.1-py3-none-manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for tls_client_python-1.15.1.1-py3-none-manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 a51573b896c6d52b5ba0cd1ece413e675ab602fcf5d3f15fc556a0e30054ce37
MD5 3a4347d91d4a581c85be8352d7ae267b
BLAKE2b-256 aaa7203c11bf7ded9803ff2241247f1012a23382b5b9623773726a5e120563d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1-py3-none-manylinux2014_armv7l.whl:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tls_client_python-1.15.1.1-py3-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tls_client_python-1.15.1.1-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 87b2f1cf598855548af29cf6541330496352f82f7424e68902960b0ff5df8ac0
MD5 485fd8184427bcc8d4100170f3420131
BLAKE2b-256 a7bd96cc9e6620fac5d9b13c14e4e3791ea79797b2a31cf06fcf5423b63196f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1-py3-none-manylinux2014_aarch64.whl:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tls_client_python-1.15.1.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tls_client_python-1.15.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d1e39ce0d3316bd47b4903eb73ee301d86b33f8254c1c4f3bd88004e74b1137
MD5 5850ae59b8914d602a458471775f2856
BLAKE2b-256 5fc5c9412d79b922ad3b86f880fa166dc773cdf1dc5f84d7d04eeb901cc11bce

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1-py3-none-macosx_11_0_arm64.whl:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tls_client_python-1.15.1.1-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tls_client_python-1.15.1.1-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 05718d19f60c1049bea207be0b78e53dbe3c9e84605277de3b08e0606d78b99b
MD5 9e32d97e651d87cc11568b1d109f8664
BLAKE2b-256 e099190c5f7c5ad56e5dce54990a8f76fdde62aaa3bd4c8d55fc55ba17b686f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tls_client_python-1.15.1.1-py3-none-macosx_10_9_x86_64.whl:

Publisher: build_workflow.yml on komAAmok/tls-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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