Skip to main content

tlsprint-python

Python HTTP client backed by the existing tlsprint Go engine: uTLS, its customized HTTP/2 transport, and all 47 built-in fingerprint presets across 13 products. The distribution name is tlsprint-python; import it as tlsprint. The unrelated PyPI package named tlsprint must not be installed in the same environment.

pip install tlsprint-python

Python 3.10 or newer is required. A compatible wheel contains the native engine and requires neither Go nor a C compiler at runtime. Platforms without a compatible wheel build from the source distribution and need Go >= 1.24 and a C compiler. This initial release is validated on macOS ARM64; other platforms are not yet validated. There are no Python runtime dependencies.

import tlsprint

print([p["key"] for p in tlsprint.list_presets(product="chrome")])
print(tlsprint.get_preset("chrome-142")["version"])

with tlsprint.Session(impersonate="chrome-142", timeout=30) as session:
    response = session.get("https://example.com", params={"q": "hello"})
    response.raise_for_status()
    print(response.status_code, response.http_version, response.text)

    response = session.post("https://httpbin.org/post", json={"hello": "world"})
    print(response.json())

# Convenience calls create and close a session for each request.
response = tlsprint.get("https://example.com", impersonate="firefox-145")

API

Session(impersonate="chrome", headers=None, timeout=30, proxy=None, verify=True, http_version="auto", allow_redirects=True, cookies=True)

  • Presets accept exact keys and the Go registry's aliases, including chrome, chrome-142, firefox-145, and safari-26.0.1. Full keys select an unambiguous capture when several presets share a version. Product aliases select the newest bundled preset, not the newest browser available online.
  • get, post, put, patch, delete, head, options, and request(method, url) accept params, headers, data, json, and timeout. data accepts bytes (including NUL bytes), strings, mappings, or form pairs. json=None explicitly sends JSON null. data and json are exclusive.
  • Timeouts are seconds for the whole request. None disables the deadline. Each request can override the session default, including with a longer value.
  • verify=True uses system trust; a PEM CA path replaces the trust pool. verify=False disables target certificate verification.
  • proxy accepts HTTP or HTTPS proxy URLs, including basic credentials. HTTPS targets use CONNECT so their TLS handshake still comes from the preset. HTTPS proxy certificates use system trust independently of target verify. Environment proxy variables are not read. SOCKS proxies are not supported.
  • http_version is auto, h1, or h2. Auto attempts HTTP/2 with the core's HTTP/1.1 fallback. Plain HTTP uses HTTP/1.1. Presets without H2 support also use HTTP/1.1; h2 does not add capabilities to those presets.
  • Cookies persist in the Go session jar by default. allow_redirects and cookies configure the session at construction. The core's redirect limit applies. Session headers may be changed between requests.
  • Responses expose status_code, status, url, http_version, headers, content, text, encoding, elapsed (a timedelta), ok, json(), and raise_for_status(). Headers are case-insensitive; headers.get_list("set-cookie") preserves repeated values.
  • Timeout, SSLError, ConnectionError, Cancelled, SessionClosed, InvalidArgument, and HTTPError are available directly from tlsprint. HTTPError.response contains the response.

Scope and lifetime

The TLS engine, transport, connection pool, cookie jar and preset registry stay in Go. Python handles the public interface, argument encoding and response objects. The private C ABI exchanges JSON metadata and raw body buffers; Python always frees returned native allocations. Session handles are integer IDs, not exposed Go pointers. Calls release the Python GIL while Go runs.

A session supports concurrent requests. Configuration affecting the transport is fixed for its lifetime; create a new session to change presets or proxies. Do not mutate session.headers or session.timeout concurrently with requests. Use a context manager or close() to cancel active requests and release pooled connections. Use multiprocessing's spawn method; using the embedded Go runtime after fork is unsupported and rejected.

This version is synchronous and buffers the whole body. It does not implement streaming, async, multipart uploads, WebSockets or HTTP/3. Large responses consume memory in both runtimes. Bodies are automatically decompressed by the Go client; response headers still describe the original encoded response. The core falls back to raw bytes for unsupported or malformed compression.

Fingerprint behavior is inherited from tlsprint, not a complete browser runtime. GREASE and cryptographic randomness vary, and fresh connections omit resumption extensions. HTTP/2 settings and ordering follow the selected preset; HTTP/1.1 header ordering is controlled by Go's standard transport. A preset's browser version label does not promise identical behavior to every feature of that browser.

Build and verify

From this directory, with Go and a C compiler installed:

uv build
uv venv .venv
uv pip install --python .venv/bin/python dist/*.whl
cd native
go build -o ../build/testserver ./testserver
go test -race ./...
cd ..
TLSPRINT_TEST_SERVER="$PWD/build/testserver" .venv/bin/python -m unittest discover -s tests -v

The source distribution contains a frozen copy of the necessary Go sources and embedded preset data, with module checksums; it builds independently of the original checkout. Building may download the pinned Go dependencies. Wheels are platform-specific but independent of CPython's extension ABI (py3-none-<platform>). Third-party license texts are included in licenses/.

Publishing to production PyPI (token supplied securely through the environment):

uv publish --trusted-publishing never dist/*

Download files

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

Source Distribution

tlsprint_python-0.1.0.tar.gz (224.8 kB view details)

Uploaded Source

Built Distribution

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

tlsprint_python-0.1.0-py3-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file tlsprint_python-0.1.0.tar.gz.

File metadata

  • Download URL: tlsprint_python-0.1.0.tar.gz
  • Upload date:
  • Size: 224.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tlsprint_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9caaeb1f3c4afebdd33b6c65c7f8f73386dbf4eb2f6bea69dd66296e4af1eb2a
MD5 6dbe05ab167f107ff02d0aff8fc15693
BLAKE2b-256 ed755defdfea70a050c5981730b129bd585e37a7e8b34db4c437701f1ef9142f

See more details on using hashes here.

File details

Details for the file tlsprint_python-0.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tlsprint_python-0.1.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tlsprint_python-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 beec3ccd6d9a92857066e6d7bb3e783d78ea482df3cae6ca505350d866c27088
MD5 d34d2227d533ecc6268cd9ebad13f35f
BLAKE2b-256 1c1d9e5a6c70fd4031341bdb76076073e4ddc2d18c18cb2eb5721ebe3b44ebb5

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

7 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page