Skip to main content

Python-TLS-Client-Async

PyPI version Python versions License

Asyncio-first TLS client for Python with advanced fingerprinting capabilities. Modern fork of Python-TLS-Client with enhanced features and active maintenance.

from async_tls_client import AsyncClient
import asyncio


async def main():
    async with AsyncClient(
            client_identifier="chrome120",
            random_tls_extension_order=True
    ) as client:
        response = await client.get("https://tls.peet.ws/api/all")
        print(f"Detected TLS fingerprint: {response.json()['tls']['ja3_hash']}")


asyncio.run(main())

Features ✨

  • Full Async Support: Built with asyncio for high-performance concurrent requests
  • Modern TLS Fingerprinting: JA3, JA4, HTTP/2 fingerprints and TLS 1.3 support
  • Client Profiles: 50+ preconfigured clients (Chrome, Firefox, Safari, iOS, Android)
  • Advanced Configuration:
    • Custom TLS cipher suites & extensions
    • HTTP/2 and QUIC protocol support
    • Certificate pinning and compression
    • Proxy support (HTTP/S, SOCKS4/5)
  • Auto-Cookie Management: Session persistence with configurable cookie jars
  • Request Manipulation: Header ordering, pseudo-header customization, and priority control

Why This Fork? 🚀

The fork was created due to the lack of updates in the original repository, while the underlying GoLang library tls-client continues to evolve actively. This project aims to keep up with the latest developments in the GoLang library and provide a modern, asynchronous interface for Python users.

Recommendations:

  • Monitor changelogs for deprecation warnings in future minor releases
  • Avoid direct reliance on internal modules like async_tls_client.structures or async_tls_client.cookies
  • Consider contributing feedback on the proposed changes through GitHub issues

Installation 📦

pip install async_tls_client

Quickstart 🚀

Basic Usage

from async_tls_client import AsyncClient
import asyncio


async def main():
    async with AsyncClient("chrome120") as client:
        response = await client.get(
            "https://httpbin.org/json",
            headers={"X-API-Key": "secret"},
            proxy="http://user:pass@proxy:port"
        )
        print(f"Status: {response.status_code}")
        print(f"Headers: {response.headers}")
        print(f"JSON: {response.json()}")


asyncio.run(main())

Advanced Configuration

from async_tls_client import AsyncClient

client = AsyncClient(
    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,
        "INITIAL_WINDOW_SIZE": 6291456,
        "MAX_HEADER_LIST_SIZE": 262144
    },
    supported_signature_algorithms=[
        "ECDSAWithP256AndSHA256",
        "PSSWithSHA256",
        "PKCS1WithSHA256",
        "ECDSAWithP384AndSHA384",
        "PSSWithSHA384",
        "PKCS1WithSHA512",
    ],
    certificate_pinning={
        "example.com": [
            "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
        ]
    }
)

Client Profiles 🕶️

Preconfigured client identifiers (https://github.com/bogdanfinn/tls-client/blob/master/profiles/profiles.go):

Browser/Framework Available Profiles
Chrome chrome_103 - chrome_133 (including PSK variants: 116_PSK, 116_PSK_PQ, 131_PSK, 133_PSK)
Firefox firefox_102 - firefox_135
Safari (Desktop) safari_15_6_1, safari_16_0, safari_ipad_15_6
Safari (iOS) safari_ios_15_5 - safari_ios_18_0
Opera opera_89 - opera_91
Android (OkHttp) okhttp4_android_7 - okhttp4_android_13
iOS (Custom) mms_ios (v1, v2, v3), mesh_ios (v1, v2), confirmed_ios, zalando_ios_mobile, nike_ios_mobile
Android (Custom) mesh_android (v1, v2), confirmed_android, zalando_android_mobile, nike_android_mobile
Cloudflare cloudscraper

Advanced Features 🔧

Custom Fingerprint Configuration

client = AsyncClient(
    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_order=["HEADER_TABLE_SIZE", "MAX_CONCURRENT_STREAMS"],
    pseudo_header_order=[":method", ":authority", ":scheme", ":path"],
    header_order=["accept", "user-agent", "accept-encoding"],
    force_http1=False,
    cert_compression_algo="brotli"
)

Certificate Pinning

client = AsyncClient(
    certificate_pinning={
        "api.bank.com": [
            "sha256/7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y=",
            "sha256/YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg="
        ]
    }
)

Proxy Support

response = await client.get(
    "https://api.example.com",
    proxy="socks5://user:pass@proxy:1080"
)

Asynchronous Design 🚧

The client leverages Python's asyncio through three key strategies:

  1. Non-blocking I/O

    • Network operations run in separate threads using asyncio.to_thread
    • Go TLS client handles remain managed in background executors
  2. Session Management

    • AsyncClient context manager handles automatic cleanup
    • Connection pooling with automatic keep-alives
    • Cookie persistence across requests
  3. Resource Optimization

    • Zero-copy body handling for large responses
    • Lazy initialization of heavy resources
    • Automatic memory cleanup of Go pointers

Packaging 📦

When using PyInstaller/PyArmor, include the shared library:

Windows

--add-binary 'async_tls_client/dependencies/tls-client-64.dll;async_tls_client/dependencies'

Linux

--add-binary 'async_tls_client/dependencies/tls-client-x86.so:async_tls_client/dependencies'

macOS

--add-binary 'async_tls_client/dependencies/tls-client-arm64.dylib:async_tls_client/dependencies'

Acknowledgements 🙏

License 📄

MIT License - See LICENSE for details

Download files

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

Source Distribution

async_tls_client-2.2.0.tar.gz (45.4 MB view details)

Uploaded Source

Built Distribution

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

async_tls_client-2.2.0-py3-none-any.whl (45.6 MB view details)

Uploaded Python 3

File details

Details for the file async_tls_client-2.2.0.tar.gz.

File metadata

  • Download URL: async_tls_client-2.2.0.tar.gz
  • Upload date:
  • Size: 45.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for async_tls_client-2.2.0.tar.gz
Algorithm Hash digest
SHA256 cbe3d64c58b9d2274d6122faddded718d1f10606ad94ef44dc05e139e94c48c9
MD5 3cbd3906450cc8e69717905a458f4e25
BLAKE2b-256 84ecb41d435aa1690a318073895efc146697188f57f92de0c40d12dc73f0be80

See more details on using hashes here.

File details

Details for the file async_tls_client-2.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for async_tls_client-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aeff7d84c2e5485efc537a1e42e026a9620ecb06adc47cac9524a3c30cd7f83f
MD5 85945f00f66e07b2c5c0b808fca9e591
BLAKE2b-256 ce28ea9f0203c858b67643c3e5b44d0cc324f6e02d45aea08a77f78544ca87e1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 files

2.1.0

2 files

2.0.4

2 files

2.0.3

2 files

2.0.2

2 files

2.0.0

2 files

1.2

2 files

1.1.1

2 files

1.1

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page