tls-client-python 1.14.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,384 @@
1
+ Metadata-Version: 2.4
2
+ Name: tls-client-python
3
+ Version: 1.14.0
4
+ Summary: High-performance Python binding for bogdanfinn/tls-client via CFFI โ€“ zero-copy, panic-proof, full TLS fingerprint control
5
+ Author: komAAmok
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/komAAmok/tls-client-python
8
+ Project-URL: Documentation, https://github.com/komAAmok/tls-client-python#readme
9
+ Project-URL: Repository, https://github.com/komAAmok/tls-client-python
10
+ Project-URL: Issues, https://github.com/komAAmok/tls-client-python/issues
11
+ Keywords: tls,tls-fingerprint,http-client,ja3,http2,http3,quic,cffi,akamai,cloudflare,anti-bot
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: MacOS :: MacOS X
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.6
20
+ Classifier: Programming Language :: Python :: 3.7
21
+ Classifier: Programming Language :: Python :: 3.8
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Programming Language :: Python :: Implementation :: CPython
27
+ Classifier: Topic :: Internet :: WWW/HTTP
28
+ Classifier: Topic :: Security
29
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
30
+ Requires-Python: <3.13,>=3.6
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: cffi>=1.14.0
34
+ Dynamic: license-file
35
+
36
+ # tls-client-python
37
+
38
+ [![PyPI version](https://img.shields.io/pypi/v/tls-client-python)](https://pypi.org/project/tls-client-python/)
39
+ [![Python](https://img.shields.io/pypi/pyversions/tls-client-python)](https://pypi.org/project/tls-client-python/)
40
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
41
+
42
+ **High-performance Python binding for [bogdanfinn/tls-client](https://github.com/bogdanfinn/tls-client) via CFFI.**
43
+
44
+ Zero-copy FFI boundary, panic-proof, full TLS fingerprint control โ€” with a familiar `requests`-style API.
45
+
46
+ ---
47
+
48
+ ## What is TLS Fingerprinting?
49
+
50
+ Some people think it is enough to change the user-agent header of a request to let the server think that the client
51
+ requesting a resource is a specific browser.
52
+ Nowadays this is not enough, because the server might use a technique to detect the client browser which is called TLS
53
+ Fingerprinting.
54
+
55
+ For a deep dive, see [this excellent article on TLS fingerprinting](https://httptoolkit.tech/blog/tls-fingerprinting-node-js/#how-does-tls-fingerprinting-work).
56
+
57
+ ## โœจ Features
58
+
59
+ | Category | Details |
60
+ |----------|---------|
61
+ | ๐Ÿ” **TLS Fingerprinting** | Impersonate Chrome, Firefox, Safari, Brave, Opera, OkHttp & more |
62
+ | ๐ŸŒ **Protocol Support** | HTTP/1.1, HTTP/2 (h2), HTTP/3 (QUIC) with automatic negotiation |
63
+ | โšก **Protocol Racing** | Chrome-style Happy Eyeballs for HTTP/2 vs HTTP/3 |
64
+ | ๐Ÿ“‹ **Header Ordering** | Control the exact order of HTTP headers per request |
65
+ | ๐Ÿ”’ **Certificate Pinning** | Pin server certificates for enhanced security |
66
+ | ๐Ÿช **Cookie Jar** | Built-in cookie handling with customisable jar |
67
+ | ๐Ÿš‡ **Proxy Support** | HTTP and SOCKS5 proxies with CONNECT auth |
68
+ | ๐Ÿ”€ **Redirect Control** | Choose whether to follow redirects per request |
69
+ | ๐Ÿ“Š **Bandwidth Tracking** | Monitor upload/download bytes in real time |
70
+ | ๐Ÿงต **Async Support** | `AsyncSession` for asyncio integration |
71
+ | ๐Ÿ›ก๏ธ **Panic-proof** | All Go panics caught and surfaced as Python exceptions |
72
+ | โš™๏ธ **Custom TLS** | Full 26-field custom TLS client configuration |
73
+
74
+ ---
75
+
76
+ ## ๐Ÿ“ฆ Installation
77
+
78
+ ```bash
79
+ pip install tls-client-python
80
+ ```
81
+
82
+ Pre-compiled binaries are included for **9 platforms** โ€” no Go toolchain required.
83
+
84
+ ### Requirements
85
+
86
+ - Python 3.6+
87
+
88
+ ---
89
+
90
+ ## ๐Ÿš€ Quick Start
91
+
92
+ ```python
93
+ from tls_client import Session
94
+
95
+ # Create a session with Chrome 146 fingerprint
96
+ session = Session(client_identifier="chrome_146")
97
+
98
+ # GET request
99
+ resp = session.get("https://httpbin.org/get")
100
+ print(resp.status_code) # 200
101
+ print(resp.text) # JSON body
102
+ print(resp.used_protocol) # "HTTP/2.0"
103
+
104
+ # POST with JSON
105
+ resp = session.post(
106
+ "https://httpbin.org/post",
107
+ body=b'{"hello":"world"}',
108
+ headers={"Content-Type": "application/json"}
109
+ )
110
+ data = resp.json()
111
+ print(data["json"]) # {"hello": "world"}
112
+ ```
113
+
114
+ ### Context Manager
115
+
116
+ ```python
117
+ with Session(client_identifier="safari_ios_18_5") as s:
118
+ resp = s.get("https://www.example.com")
119
+ print(resp.status_code)
120
+ ```
121
+
122
+ ### Async Usage
123
+
124
+ ```python
125
+ import asyncio
126
+ from tls_client import AsyncSession
127
+
128
+ async def main():
129
+ async with AsyncSession(client_identifier="firefox_148") as s:
130
+ resp = await s.get("https://httpbin.org/get")
131
+ print(resp.json())
132
+
133
+ asyncio.run(main())
134
+ ```
135
+
136
+ ---
137
+
138
+ ## ๐Ÿ–ฅ๏ธ Supported Platforms
139
+
140
+ Pre-compiled native libraries are bundled for these platforms:
141
+
142
+ | OS | Architecture | Binary |
143
+ |----|-------------|--------|
144
+ | **Windows** | x86-64 | `tls-client-windows-amd64.dll` |
145
+ | **Windows** | x86 (32-bit) | `tls-client-windows-386.dll` |
146
+ | **macOS** | x86-64 | `tls-client-darwin-amd64.dylib` |
147
+ | **macOS** | ARM64 (Apple Silicon) | `tls-client-darwin-arm64.dylib` |
148
+ | **Linux** | x86-64 (glibc) | `tls-client-linux-amd64.so` |
149
+ | **Linux** | x86 (32-bit, glibc) | `tls-client-linux-386.so` |
150
+ | **Linux** | ARM64 | `tls-client-linux-arm64.so` |
151
+ | **Linux** | ARMv7 | `tls-client-linux-arm.so` |
152
+ | **Alpine Linux** | x86-64 (musl) | `tls-client-alpine-amd64.so` |
153
+
154
+ The correct binary is automatically selected at runtime. Override via `TLS_CLIENT_LIB` environment variable.
155
+
156
+ ---
157
+
158
+ ## ๐ŸŽญ Supported Browser Profiles โ€” 79 Identifiers
159
+
160
+ Set `client_identifier` in `Session()` to impersonate any of these browsers. Inspect the full list at runtime:
161
+
162
+ ```python
163
+ from tls_client import list_client_identifiers, SUPPORTED_CLIENT_IDENTIFIERS
164
+
165
+ print(len(list_client_identifiers())) # 79
166
+ for browser, ids in SUPPORTED_CLIENT_IDENTIFIERS.items():
167
+ print(f"{browser}: {len(ids)} profiles")
168
+ ```
169
+
170
+ ### ๐ŸŒ Chrome โ€” 24 Profiles
171
+
172
+ | Identifier | Notes |
173
+ |-----------|-------|
174
+ | `chrome_103` โ€” `chrome_112` | Chrome Stable 103โ€“112 |
175
+ | `chrome_116_PSK` | Chrome 116 with PSK key exchange |
176
+ | `chrome_116_PSK_PQ` | Chrome 116 with PSK + Post-Quantum |
177
+ | `chrome_117` | Chrome 117 |
178
+ | `chrome_120` | Chrome 120 |
179
+ | `chrome_124` | Chrome 124 |
180
+ | `chrome_130_PSK` | Chrome 130 with PSK |
181
+ | `chrome_131` ยท `chrome_131_PSK` | Chrome 131 (standard & PSK) |
182
+ | `chrome_133` ยท `chrome_133_PSK` | Chrome 133 (standard & PSK) |
183
+ | `chrome_144` ยท `chrome_144_PSK` | Chrome 144 (standard & PSK) |
184
+ | `chrome_146` ยท `chrome_146_PSK` | Chrome 146 โ€” **default** (standard & PSK) |
185
+
186
+ ### ๐ŸฆŠ Firefox โ€” 16 Profiles
187
+
188
+ | Identifier | Notes |
189
+ |-----------|-------|
190
+ | `firefox_102` ยท `firefox_104` ยท `firefox_105` ยท `firefox_106` | Firefox 102โ€“106 |
191
+ | `firefox_108` ยท `firefox_110` | Firefox 108 ยท 110 |
192
+ | `firefox_117` ยท `firefox_120` ยท `firefox_123` | Firefox 117โ€“123 |
193
+ | `firefox_132` ยท `firefox_133` ยท `firefox_135` | Firefox 132โ€“135 |
194
+ | `firefox_146_PSK` | Firefox 146 with PSK |
195
+ | `firefox_147` ยท `firefox_147_PSK` | Firefox 147 (standard & PSK) |
196
+ | `firefox_148` | Firefox 148 |
197
+
198
+ ### ๐Ÿ Safari โ€” 10 Profiles
199
+
200
+ | Identifier | Device |
201
+ |-----------|--------|
202
+ | `safari_15_6_1` | Safari 15.6.1 (macOS) |
203
+ | `safari_16_0` | Safari 16.0 (macOS) |
204
+ | `safari_ipad_15_6` | Safari 15.6 (iPadOS) |
205
+ | `safari_ios_15_5` ยท `safari_ios_15_6` | Safari iOS 15.5โ€“15.6 |
206
+ | `safari_ios_16_0` ยท `safari_ios_17_0` | Safari iOS 16 ยท 17 |
207
+ | `safari_ios_18_0` ยท `safari_ios_18_5` | Safari iOS 18 ยท 18.5 |
208
+ | `safari_ios_26_0` | Safari iOS 26 |
209
+
210
+ ### ๐Ÿฆ Brave โ€” 2 Profiles
211
+
212
+ | Identifier | Notes |
213
+ |-----------|-------|
214
+ | `brave_146` | Brave Browser 146 |
215
+ | `brave_146_PSK` | Brave 146 with PSK |
216
+
217
+ ### ๐ŸŽญ Opera โ€” 3 Profiles
218
+
219
+ | Identifier |
220
+ |-----------|
221
+ | `opera_89` ยท `opera_90` ยท `opera_91` |
222
+
223
+ ### ๐Ÿค– OkHttp (Android) โ€” 7 Profiles
224
+
225
+ | Identifier |
226
+ |-----------|
227
+ | `okhttp4_android_7` โ€” `okhttp4_android_13` |
228
+
229
+ ### ๐Ÿ“ฑ Mobile / App SDKs โ€” 16 Profiles
230
+
231
+ | Category | Identifiers |
232
+ |----------|------------|
233
+ | Zalando | `zalando_android_mobile` ยท `zalando_ios_mobile` |
234
+ | Nike | `nike_ios_mobile` ยท `nike_android_mobile` |
235
+ | MMS | `mms_ios` ยท `mms_ios_1` ยท `mms_ios_2` ยท `mms_ios_3` |
236
+ | Mesh | `mesh_ios` ยท `mesh_ios_1` ยท `mesh_ios_2` ยท `mesh_android` ยท `mesh_android_1` ยท `mesh_android_2` |
237
+ | Confirmed | `confirmed_ios` ยท `confirmed_android` |
238
+
239
+ ### โ˜๏ธ Cloudflare-specific โ€” 1 Profile
240
+
241
+ | Identifier | Notes |
242
+ |-----------|-------|
243
+ | `cloudscraper` | Custom profile tuned for Cloudflare-protected sites |
244
+
245
+ ---
246
+
247
+ ## ๐Ÿ”ง Advanced Usage
248
+
249
+ ### Custom TLS Client (Full Control)
250
+
251
+ Set `custom_tls_client` with up to 26 fields to bypass `client_identifier` entirely:
252
+
253
+ ```python
254
+ session = Session(custom_tls_client={
255
+ "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",
256
+ "h2_settings": {"HEADER_TABLE_SIZE": 65536, "MAX_CONCURRENT_STREAMS": 1000},
257
+ "h2_settings_order": ["HEADER_TABLE_SIZE", "MAX_CONCURRENT_STREAMS"],
258
+ "pseudo_header_order": [":method", ":authority", ":scheme", ":path"],
259
+ "connection_flow": 1048576,
260
+ "key_share_curves": ["X25519", "P256"],
261
+ "alpn_protocols": ["h2", "http/1.1"],
262
+ "supported_versions": ["1.3", "1.2"],
263
+ "stream_id": 3,
264
+ })
265
+ ```
266
+
267
+ ### Certificate Pinning
268
+
269
+ ```python
270
+ session = Session(
271
+ certificate_pinning_hosts={
272
+ "example.com": ["sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="]
273
+ }
274
+ )
275
+ ```
276
+
277
+ ### Client Certificates (mTLS)
278
+
279
+ ```python
280
+ session = Session(
281
+ client_certificates=[{
282
+ "cert_pem": open("client.crt", "rb").read(),
283
+ "key_pem": open("client.key", "rb").read(),
284
+ }]
285
+ )
286
+ ```
287
+
288
+ ### Stream Response to Disk
289
+
290
+ ```python
291
+ resp = session.stream_to_file(
292
+ "GET", "https://httpbin.org/image/png",
293
+ output_path="/tmp/image.png"
294
+ )
295
+ print(resp.status_code) # response metadata still available
296
+ ```
297
+
298
+ ### Per-Request Overrides
299
+
300
+ All `Session` constructor parameters can be overridden per request:
301
+
302
+ ```python
303
+ s = Session(client_identifier="chrome_146")
304
+ # Override fingerprint for a single request
305
+ resp = s.get("https://tls.peet.ws/api/all", client_identifier="firefox_148")
306
+ ```
307
+
308
+ ---
309
+
310
+ ## ๐Ÿ”ฌ Architecture
311
+
312
+ | Layer | Technology |
313
+ |-------|-----------|
314
+ | **Go Engine** | `bogdanfinn/tls-client` compiled as C shared library (`-buildmode=c-shared`) |
315
+ | **FFI Boundary** | Raw C structs via CFFI โ€” no JSON serialization overhead |
316
+ | **Memory Safety** | `ffi.gc(resp, FreeResponse)` โ€” Go panics surfaced as `RuntimeError` |
317
+ | **Python API** | `requests`-style `Session`, `Response`, `AsyncSession` |
318
+
319
+ ---
320
+
321
+ ## ๐Ÿ“š API Reference
322
+
323
+ ### Session
324
+
325
+ | Method | Description |
326
+ |--------|-------------|
327
+ | `get(url, **kwargs)` | HTTP GET |
328
+ | `post(url, **kwargs)` | HTTP POST |
329
+ | `put(url, **kwargs)` | HTTP PUT |
330
+ | `delete(url, **kwargs)` | HTTP DELETE |
331
+ | `head(url, **kwargs)` | HTTP HEAD |
332
+ | `patch(url, **kwargs)` | HTTP PATCH |
333
+ | `execute_request(method, url, **kwargs)` | Generic request with full options |
334
+ | `typed_request(Request)` | Strongly-typed request |
335
+ | `stream_to_file(method, url, path)` | Stream response body to disk |
336
+ | `clear_client_pool()` | Close idle connections (static) |
337
+
338
+ ### Response
339
+
340
+ | Property / Method | Description |
341
+ |-------------------|-------------|
342
+ | `status_code` | HTTP status code (int) |
343
+ | `headers` | Response headers (dict of list) |
344
+ | `content` | Raw bytes body |
345
+ | `text` | Decoded text body |
346
+ | `encoding` | Detected charset |
347
+ | `url` | Final URL after redirects |
348
+ | `cookies` | Response cookies dict |
349
+ | `used_protocol` | Protocol used (e.g. `HTTP/2.0`) |
350
+ | `ok` | `True` if `status_code < 400` |
351
+ | `reason` | HTTP reason phrase |
352
+ | `json()` | Parse body as JSON |
353
+ | `raise_for_status()` | Raise `RuntimeError` on 4xx/5xx |
354
+
355
+ ---
356
+
357
+ ## ๐Ÿ”— Credits
358
+
359
+ This project is a Python binding for **[bogdanfinn/tls-client](https://github.com/bogdanfinn/tls-client)**, which itself is built upon:
360
+
361
+ - [Carcraftz/fhttp](https://github.com/Carcraftz/fhttp)
362
+ - [Carcraftz/utls](https://github.com/Carcraftz/utls)
363
+ - [refraction-networking/utls](https://github.com/refraction-networking/utls)
364
+
365
+ ---
366
+
367
+ ## ๐Ÿ“„ License
368
+
369
+ MIT โ€” see [LICENSE](LICENSE).
370
+
371
+ ---
372
+
373
+ ## ๐Ÿ™ Community
374
+
375
+ Join the [Discord server](https://discord.gg/7Ej9eJvHqk) for support and discussion.
376
+
377
+ ---
378
+
379
+ <p align="center">
380
+ <em>Powered by</em><br>
381
+ <a href="https://jb.gg/OpenSource">
382
+ <img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg" alt="JetBrains logo." height="40">
383
+ </a>
384
+ </p>
@@ -0,0 +1,16 @@
1
+ tls_client/__init__.py,sha256=3Lz-JNeOKxKVDHsL-6tAs4mnKSBf5s35MjEkvjmgPiU,1094
2
+ tls_client/_core.py,sha256=tubHT-SLkEqZFlfB9Et7FaR8L4G7ZbFCeOcaFfK_ozM,75582
3
+ tls_client/bin/tls-client-alpine-amd64.so,sha256=ZkRRkNbkT71aHjUnPdCHlNiZnaw_cX8RJbHWTeRDi1k,11986032
4
+ tls_client/bin/tls-client-darwin-amd64.dylib,sha256=WLOdYzzHRxFntS-_LKsrBTFvBg7f51TCaU3WTt8Ycl0,10827352
5
+ tls_client/bin/tls-client-darwin-arm64.dylib,sha256=ZKKlDZBXNm9yuyPLtSPL6j-RkQqGI8BOsvoiez4fg2M,10263408
6
+ tls_client/bin/tls-client-linux-386.so,sha256=g0n07pvvOWZYhUVSYPCVOxSCD6vUro8phbsI5_RNcMg,11050776
7
+ tls_client/bin/tls-client-linux-amd64.so,sha256=befGXqbTENvDdNjNDpLY7COL2NqovFChn5MRUq3_eEk,11982096
8
+ tls_client/bin/tls-client-linux-arm.so,sha256=D9rOtSyvAN9guw3bym8mkk1lD0T2Os9uD6iU7-CKMHo,11016480
9
+ tls_client/bin/tls-client-linux-arm64.so,sha256=3qRxd0lwSglnHjSf9CRDUOJ8gWHOLLL5QutgofF0314,11355736
10
+ tls_client/bin/tls-client-windows-386.dll,sha256=bEi94W2Cb-QPc64vWxiyWkVOzVVAh4JRDvoyPqO4Mfo,10581504
11
+ tls_client/bin/tls-client-windows-amd64.dll,sha256=RA-ahcPHj9mnJuZUVex4EwiYt1CvTLY_NTkfHQ0_AWY,11048448
12
+ tls_client_python-1.14.0.dist-info/licenses/LICENSE,sha256=fauaTdZph_vldtU8HuBHwZNyXfb0-sZ94xWhJ0F_0VE,1662
13
+ tls_client_python-1.14.0.dist-info/METADATA,sha256=E3ioC5ayejpivI27Wr1cwjhF70QX3-HcAqfZ5DSJBhs,12769
14
+ tls_client_python-1.14.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
15
+ tls_client_python-1.14.0.dist-info/top_level.txt,sha256=yLrfQtbTRfECzPN62knWdGNmbhcPRev1grCAMuEsEz0,11
16
+ tls_client_python-1.14.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2023, Bogdan Finn
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ 3. All advertising materials mentioning features or use of this software
12
+ must display the following acknowledgement:
13
+ This product includes software developed by the <organization>.
14
+ 4. Neither the name of the <organization> nor the
15
+ names of its contributors may be used to endorse or promote products
16
+ derived from this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
19
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27
+ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1 @@
1
+ tls_client