Skip to main content

tlsmask

Python HTTP requests with a real browser's TLS and HTTP/2 fingerprint.

PyPI Python Downloads CI License

bundles tls-client v1.18.1

tlsmask makes HTTP requests from Python that look like they come from Chrome, Firefox or Safari. Not just the headers: the TLS handshake and the HTTP/2 settings match the browser too. It runs bogdanfinn's tls-client, a Go library, and ships its latest official build inside the package.

It is also a drop-in replacement for the tls-client package, which hasn't had a release since February 2024.

import tlsmask

with tlsmask.Session("chrome_150") as session:
    r = session.get("https://tls.peet.ws/api/all")
    print(r.status_code, r.protocol)  # 200 HTTP/2.0
    print(r.json()["tls"]["ja4"])  # Chrome's fingerprint, not Python's

Why

Every HTTPS connection starts with a TLS "ClientHello": a list of the ciphers, extensions and curves the client supports, in a particular order. Each browser sends its own recognisable version (often summarised as a JA3 or JA4 fingerprint), and so does Python. A server can tell them apart before it reads a single header, which is why requests with a Chrome User-Agent still doesn't look like Chrome.

bogdanfinn's tls-client reproduces real browsers' handshakes and HTTP/2 behaviour. The tls-client package made it usable from Python, but it stopped at version 1.0.1. It still bundles tls-client v1.7.2, so its newest browser is Chrome 120, and a number of its bugs were never fixed.

tlsmask carries on from there: the current library, the same API, those bugs fixed, and a weekly check for new tls-client releases.

tlsmask compared with tls-client

tls-client (the old wrapper) tlsmask
bogdanfinn/tls-client inside v1.7.2 v1.18.1
Browser & app profiles 51 86
Newest Chrome 120 154
Newest Firefox 120 148
Newest iOS Safari 16.0 26.0
Brave none 146
Last updated Feb 2024 Nov 2026
Native library checked against a pinned SHA-256 no yes, at build and at load
Keeps itself current no yes, a weekly bot

Installation

pip install tlsmask

Prebuilt wheels are available for:

  • Windows, 64-bit and 32-bit
  • macOS 13 or newer, Apple Silicon and Intel
  • Linux x86-64, ARM64 and ARMv7 (glibc 2.17 or newer)

Each wheel already contains the tls-client library for its platform, so nothing is downloaded when your code runs. tlsmask needs Python 3.9 or newer and has no other dependencies.

Usage

import tlsmask

session = tlsmask.Session("chrome_150")
session.headers.update(
    {
        "User-Agent": (
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
            "(KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36"
        ),
        "Accept-Language": "en-US,en;q=0.9",
    }
)

r = session.get("https://example.com", params={"q": "tls"})
print(r.status_code, r.headers["content-type"])

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

session.close()

With asyncio:

import asyncio

import tlsmask


async def main():
    async with tlsmask.AsyncSession("firefox_148") as session:
        pages = await asyncio.gather(
            *(session.get(f"https://example.com/?page={i}") for i in range(10))
        )
        print([page.status_code for page in pages])


asyncio.run(main())

The guide covers the rest: header order, cookies, proxies, redirects, timeouts, errors, threads, custom TLS fingerprints and how to check your install.

Switching from tls-client

- import tls_client
+ import tlsmask as tls_client

For most code that's the only change. The constructor arguments, the request methods, response.json() and the session.cookies helpers work the same way. A few things behave differently on purpose, mostly because the old behaviour was a bug:

tls-client tlsmask
Unknown client_identifier (including typos like chrome112) silently sends a different browser raises ValueError and suggests the closest names
A panic inside the Go library kills the whole Python process raises TLSClientException (catch_panics is on by default)
proxies={"https": ...} ignored, so the request goes out without the proxy used
post(json=...) adds Content-Type to every later request adds it to that request only
Binary responses (images, PDFs) corrupted returned byte for byte
Header order tls-client's own order the order you wrote them in (or header_order=)
cert_compression_algo silently ignored by current tls-client translated to the new setting
params on a URL that already has ? url?a=1?b=2 url?a=1&b=2
Deleting a cookie still sent, because a second copy lives inside Go gone from the next request
Different timeout_seconds or insecure_skip_verify per request ignored after the first request honoured every time
Default profile chrome_120 tls-client's current default (tlsmask.DEFAULT_PROFILE)
get(url, cookies={...}) also stored those cookies in session.cookies sends them with that request only, and only to that site, even across redirects
A proxy written as host:port failed treated as http://host:port, like requests
Authorization on a redirect kept whenever the host name matches kept only on the same origin, or on an upgrade from http to https
client_identifier=None built a client from whatever was set, failing later if something was missing checks up front that ja3_string and the settings its extensions need are there, and raises ValueError naming what's missing; ALPN defaults to what browsers send
additional_decode= decoded one extra encoding not needed any more (tls-client decodes everything); it warns and is ignored

The old misspelled TLSClientExeption still works. If your code imports tls_client.settings.ClientIdentifiers, use tlsmask.ClientIdentifiers instead. response.headers is case-insensitive now, so use dict(response.headers) where you need a plain dict (for json.dumps, say).

Choosing a profile

For most uses, pick a current browser, such as the default (tlsmask.DEFAULT_PROFILE), firefox_148 or safari_ios_26_0. Send a User-Agent that matches the profile, because a Firefox User-Agent over a Chrome handshake stands out on its own. The _PSK variants resume TLS sessions the way a returning visitor's browser does.

tlsmask.PROFILES holds every name, and editors autocomplete them through the tlsmask.ClientIdentifier type.

All 86 profiles in tls-client v1.18.1
Family Profiles
Chrome chrome_103 chrome_104 chrome_105 chrome_106 chrome_107 chrome_108 chrome_109 chrome_110 chrome_111 chrome_112 chrome_116_PSK chrome_116_PSK_PQ chrome_117 chrome_120 chrome_124 chrome_130_PSK chrome_131 chrome_131_PSK chrome_133 chrome_133_PSK chrome_144 chrome_144_PSK chrome_146 chrome_146_PSK chrome_150 chrome_150_PSK chrome_152 chrome_152_PSK chrome_154 chrome_154_PSK
Firefox firefox_102 firefox_104 firefox_105 firefox_106 firefox_108 firefox_110 firefox_117 firefox_120 firefox_123 firefox_132 firefox_133 firefox_135 firefox_146_PSK firefox_147 firefox_147_PSK firefox_148
Safari (iOS & iPadOS) safari_ios_15_5 safari_ios_15_6 safari_ios_16_0 safari_ios_17_0 safari_ios_18_0 safari_ios_18_5 safari_ios_26_0 safari_ipad_15_6
Safari (macOS) safari_15_6_1 safari_16_0 safari_27_2
Opera opera_89 opera_90 opera_91
Brave brave_146 brave_146_PSK
Mobile apps & others cloudscraper confirmed_android confirmed_ios mesh_android mesh_android_1 mesh_android_2 mesh_ios mesh_ios_1 mesh_ios_2 mms_ios mms_ios_1 mms_ios_2 mms_ios_3 nike_android_mobile nike_ios_mobile okhttp4_android_7 okhttp4_android_8 okhttp4_android_9 okhttp4_android_10 okhttp4_android_11 okhttp4_android_12 okhttp4_android_13 zalando_android_mobile zalando_ios_mobile

Where the library comes from

The native part of tlsmask is bogdanfinn's own release file, byte for byte. It isn't rebuilt or modified.

  1. When a wheel is built, the file is downloaded from tls-client's GitHub releases. The build refuses it unless its SHA-256 matches both the hash pinned in tlsmask/_pins.py and the digest GitHub publishes for the release.
  2. The first time your program makes a request, tlsmask hashes the file again and won't load it if it doesn't match.
  3. Releases are published to PyPI from GitHub Actions with trusted publishing and signed attestations, and every GitHub release includes a SHA256SUMS file.

To check your own installation:

$ python -m tlsmask
tlsmask     1.16.0
tls-client  1.16.0 (github.com/bogdanfinn/tls-client)
platform    win32/AMD64 (64-bit Python) -> windows-amd64
library     OK: ...\tlsmask\bin\tls-client-windows-64-1.16.0.dll (sha256 53dca636..., as pinned)

Staying up to date

Every Monday a scheduled job looks for a new tls-client release. When there is one, it downloads and verifies every file, reads the new list of profiles, compares the library's API with the previous version, and runs the full test suite on Windows, macOS and Linux, on both Intel and ARM machines.

If nothing important changed and the release is at least a week old, a new tlsmask version is published automatically. Anything unusual, like a removed profile or a changed API, waits for a person to look at it first.

FAQ

Is this an official bogdanfinn project? No. tlsmask is an independent project and isn't affiliated with or endorsed by Bogdan Finn. It bundles his library unmodified. Please report tlsmask problems here rather than to him.

Does it work on Alpine Linux? Not at the moment. tls-client's Alpine (musl) build can't be loaded into Python, so there is no Alpine wheel. In Docker, use a glibc-based image such as python:3.12-slim instead.

My platform has no wheel. Get a build of tls-client for it (from its releases, or build it yourself) and point tlsmask at the file with the TLSMASK_LIBRARY_PATH environment variable. On such a platform pip install tlsmask installs from the source distribution, which has no library of its own.

Does it work with multiprocessing? Yes. The library is only loaded when the first request is made, so child processes are fine as long as the parent hadn't made a request before it forked. If in doubt, use the spawn start method (the default on Windows and macOS).

Why aren't redirects followed by default? tls-client didn't follow them by default, so existing code keeps working. Pass allow_redirects=True.

What is it for? Making requests that look like a real browser: testing your own site's bot protection, research, or talking to APIs that turn away non-browser clients. Please respect the terms of the sites you use it with.

Contributing

Bug reports and pull requests are welcome. To set up a development copy:

git clone https://github.com/Ubaidullah71/tlsmask && cd tlsmask
python -m venv .venv && source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
python scripts/fetch_binaries.py  # downloads and verifies this machine's library into tlsmask/bin/
pytest                            # unit tests, plus tests against the real library and a local server
pytest -m live                    # fingerprint checks against a public echo service

tlsmask/_pins.py, tlsmask/profiles.py, tlsmask/_version.py and the tables in this README are generated by scripts/render.py, so please don't edit them by hand.

Credits

License

tlsmask's own code is under the MIT license. The bundled tls-client library is under the BSD 3-Clause license (LICENSE-tls-client).

Metadata

Release files for tlsmask 1.18.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tlsmask 1.18.1
File Size Uploaded Provenance Actions
tlsmask-1.18.1.tar.gz 70.1 kB With provenance Details for tlsmask-1.18.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tlsmask 1.18.1
File Actions
tlsmask-1.18.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for tlsmask-1.18.1-py3-none-win_amd64.whl
tlsmask-1.18.1-py3-none-win32.whl Python 3 none Windows x86-32 Details for tlsmask-1.18.1-py3-none-win32.whl
tlsmask-1.18.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for tlsmask-1.18.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
tlsmask-1.18.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details for tlsmask-1.18.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
tlsmask-1.18.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for tlsmask-1.18.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
tlsmask-1.18.1-py3-none-macosx_13_0_x86_64.whl Python 3 none macOS 13.0+ x86-64 Details for tlsmask-1.18.1-py3-none-macosx_13_0_x86_64.whl
tlsmask-1.18.1-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details for tlsmask-1.18.1-py3-none-macosx_13_0_arm64.whl

Total release size: 55.2 MB

Release files / tlsmask-1.18.1.tar.gz

Download URL tlsmask-1.18.1.tar.gz
Size 70.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3647c7b85c9c48e0e44feb25a413bee2b05faf8b52286fd1115666d311d04d1f
BLAKE2b-256 checksum
How to use checksums
954b5e3725b3abce003f357bdb51ecc59a624daf2ad012905086139362f65722
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / tlsmask-1.18.1-py3-none-win_amd64.whl

Download URL tlsmask-1.18.1-py3-none-win_amd64.whl
Size 9.2 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
b057bb8f27865161b3ee0ab09ea8493fe494e7e4c944286492b6ae87fb398f17
BLAKE2b-256 checksum
How to use checksums
a92cf2651cb3da5a8f571247d7973c9cfa1ebadb0a45c4bb1ab3a8a7480319b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / tlsmask-1.18.1-py3-none-win32.whl

Download URL tlsmask-1.18.1-py3-none-win32.whl
Size 9.1 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
594979fa6bdff566edd4061f75cc66a92f67cc42c40dff8840d6d04d361a4d5c
BLAKE2b-256 checksum
How to use checksums
217065a647f72508b42e710565ba62e9da40b26428baf633618b5d4d26e01241
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / tlsmask-1.18.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL tlsmask-1.18.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 9.3 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0129877147bd4b4864e5ba702f59dd7155076d1f65d08e3683fb677692154588
BLAKE2b-256 checksum
How to use checksums
d71f156ad1db719799724452853d8d9468bc4d5c0d7e1eb3a3cd8e2fac9b4295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / tlsmask-1.18.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL tlsmask-1.18.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 8.8 MB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
3b7814f6d552634e1ea76e5bf8d6e7fbfc13aa16f2afcc7e38996f86b96a58a8
BLAKE2b-256 checksum
How to use checksums
7710dad763a0e92083001c2a4b43110adb94625260ee474d81cc29ab40a7ff15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / tlsmask-1.18.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL tlsmask-1.18.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 8.5 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
15c0176a3b6de0d2db47103280efc0ffdd79af4e144fd9372ce388c5b841de95
BLAKE2b-256 checksum
How to use checksums
42339758f2df66140a5631eb395455da1e88e2ae21e60f455181ddc0c92ba5ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / tlsmask-1.18.1-py3-none-macosx_13_0_x86_64.whl

Download URL tlsmask-1.18.1-py3-none-macosx_13_0_x86_64.whl
Size 5.3 MB
Tags Python 3 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
5159a42eff43b4b68d7618855595b87f41e9ef5902e0f1aef470db04191db780
BLAKE2b-256 checksum
How to use checksums
f2e5f2e518300e84620ddf914f6a930a3da449decef5775cd405aa1c5f724994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / tlsmask-1.18.1-py3-none-macosx_13_0_arm64.whl

Download URL tlsmask-1.18.1-py3-none-macosx_13_0_arm64.whl
Size 4.9 MB
Tags Python 3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
9c230836eb728334d24a9289c30c14eb1172bcf81d6941a1fe0b9e5582eacbd5
BLAKE2b-256 checksum
How to use checksums
753c8ded18f52c9f94ab368d01bb3033a0c2e29c054a567c93ff185a6bd9f675
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for tlsmask 1.18.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for tlsmask-1.18.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.18.1 This release

8 release files Full provenance

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