Metadata-Version: 2.3
Name: tlsfp
Version: 4.0.0
Summary: Browser-accurate TLS/HTTP fingerprint client (JA3/JA4, Akamai H2/H3) with a requests-style Python API
Description-Content-Type: text/markdown
Keywords: tls,tls-fingerprint,ja3,ja4,akamai,http2,http3,clienthello,chrome,firefox,scraping,anti-bot,requests,curl-cffi
Requires-Python: >=3.9
Platform: Linux x86_64. The wheel bundles libtlsfp.so and its non-glibc dependencies; source builds link the system OpenSSL (>= 3.0), nghttp2 and brotli.
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules

# tlsfp (Python)

`tlsfp` is a browser-accurate TLS/HTTP client. The C++ core emits the exact
ClientHello and HTTP frames a real browser emits, so the server sees the same
**JA3 / JA4 / Akamai H2** fingerprint as Chrome 157, Firefox 160, Firefox 151
or Edge 152 — not Python's.

The Python layer is a **pure standard-library `ctypes` binding** around the
`libtlsfp.so` C ABI: no compiled extension, no third-party package, no
monkey-patching.

```python
from tlsfp import Session

with Session(profile="chrome-157", proxy="http://127.0.0.1:7897") as s:
    r = s.get("https://tls.peet.ws/api/all")
    print(r.status_code, r.http_version, r.ja4)
    print(r.json()["tls"]["ja4"])
```

## Install

```sh
pip install tlsfp
```

Two artifacts are published for 4.0.0:

| artifact | platform | what it needs at runtime |
| --- | --- | --- |
| `tlsfp-4.0.0-py3-none-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl` | Linux x86-64, glibc >= 2.28 (Ubuntu 20.04+, Debian 11+, RHEL/Alma/Rocky 8+, Arch, Manjaro) | nothing: `libtlsfp.so`, OpenSSL 4.1, nghttp2, brotli and zstd are bundled inside the wheel |
| `tlsfp-4.0.0.tar.gz` (sdist) | Linux x86-64 (other architectures if the C++ core builds there) | a C++20 compiler, CMake >= 3.20, and the development packages of OpenSSL (>= 3.0), nghttp2, brotli, zlib, plus nlohmann-json |

pip picks the wheel when the platform matches and falls back to the sdist.
For the sdist on Debian/Ubuntu:

```sh
sudo apt install build-essential cmake libssl-dev libnghttp2-dev libbrotli-dev \
                 zlib1g-dev libzstd-dev nlohmann-json3-dev
pip install tlsfp --no-binary tlsfp   # force a source build
```

There is no Windows or macOS build in 4.0.0: the core is Linux/epoll only.

### Where the library comes from

The binding loads `libtlsfp.so` in this order: `$TLSFP_LIB`, then
`libtlsfp.so` next to the module (what the wheel installs), then
`../build/libtlsfp.so`, `../build/libtlsfp.so.4`, `../../lib/libtlsfp.so`, then
the system loader path. Set `TLSFP_LIB` to point at your own build of the C
library and the Python side will use it unchanged.

## Entry points

| import | what it does |
| --- | --- |
| `tlsfp.Session` | requests-style client: `get/post/put/delete/head/request`, `Response.status_code/.headers/.text/.json()/.content`, cookie jar, proxies (`http://`, `socks5://`), redirects, per-request timeouts, `stream=True` + `iter_content()`, WebSocket helper |
| `tlsfp_multi.MultiAsyncSession` | `asyncio` client over one C++ reactor for a URL list: `await s.gather(urls)` / `async for r in s.stream(urls)` with `max_inflight` (use it as a plain `with` block) |
| `tlsfp_reuse.ReuseSession` | keep-alive connection reuse: HTTP/2 multiplexing on one TLS session, h1 keep-alive, per-result `reused`/`mux` flags and `stats()` |
| `tlsfp.AsyncSession` | asyncio client over the native extension's pool — **not usable in 4.0.0**, see below |

Error classes (`tlsfp.Timeout`, `tlsfp.CertificateError`, `tlsfp.ConnectError`,
...) carry the C ABI status code in `.status`.

Built-in profiles: `chrome-157`, `chrome-157-linux`, `firefox-160`,
`firefox-151`, `edge-152`. `Session(profile="FILE.json")` loads or extends a
profile from disk.

## What 4.0.0 does *not* include

* the optional native extension `_tlsfp_native` (`-DTLSFP_PYTHON=ON`,
  `TLSFP_NATIVE=1`). `tlsfp.native_available()` is `False` and
  `tlsfp.AsyncSession(...)` raises `ModuleNotFoundError: _tlsfp_native`,
  because this release deliberately ships only the ctypes path. Use
  `tlsfp_multi.MultiAsyncSession` or `tlsfp_reuse.ReuseSession` for concurrent
  work; build the core yourself with `-DTLSFP_PYTHON=ON` if you need the
  native class or `AsyncSession`;
* HTTP/3 (`--http3`) and its profiles;
* the BoringSSL TLS 1.2 backend and the TLS 1.0/1.1 legacy transport;
* the `requests` drop-in shim (`python/compat`), which is source-only.

`Python 3.9` is the floor claimed by the metadata; the wheel itself is
`py3-none` because the binding is pure Python, so any CPython 3 on a matching
platform can install it.

## Fingerprint parity depends on the bundled OpenSSL

Chrome 157 and Firefox 160 offer the hybrid post-quantum group
`X25519MLKEM768` (0x11ec). It is only implemented by OpenSSL >= 3.5. The wheel
bundles OpenSSL 4.1, so the wheel sends a real ML-KEM key share, exactly like a
current browser. A source build against an older system OpenSSL still links and
runs, but that group gets no key share; JA3/JA4/Akamai signatures are unchanged
(they hash extension types, cipher lists and ALPN, not key-share payloads), so
only post-quantum confidentiality is lost. Use `tlsfp.version()` and
`tlsfp.ABI_VERSION` at runtime to see what is loaded.

## License

No `LICENSE` file ships in the repository or in this artifact, so no license is
granted for redistribution or commercial use by this package alone.

## Documentation

The repository ships the full C++ and Python documentation (`docs/PYTHON.md`,
`docs/C-ABI.md`, `docs/HTTP-CLIENT.md`, `docs/COOKIES.md`, ...). The Python
binding is generated from, and stays in lockstep with, the stable C ABI
described in `docs/C-ABI.md`.
