4
4
[ ![ Python versions] ( https://img.shields.io/pypi/pyversions/async_tls_client.svg )] ( https://pypi.org/project/async_tls_client/ )
5
5
[ ![ License] ( https://img.shields.io/badge/license-MIT-blue.svg )] ( https://opensource.org/licenses/MIT )
6
6
7
- Asyncio-first TLS client for Python with advanced fingerprinting capabilities. Modern fork of [ Python-TLS-Client] ( https://github.com/FlorianREGAZ/Python-Tls-Client ) with enhanced features and active maintenance.
7
+ Asyncio-first TLS client for Python with advanced fingerprinting capabilities. Modern fork
8
+ of [ Python-TLS-Client] ( https://github.com/FlorianREGAZ/Python-Tls-Client ) with enhanced features and active maintenance.
8
9
9
10
``` python
10
11
from async_tls_client import AsyncClient
11
12
import asyncio
12
13
14
+
13
15
async def main ():
14
16
async with AsyncClient(
15
- client_identifier = " chrome120" ,
16
- random_tls_extension_order = True
17
+ client_identifier = " chrome120" ,
18
+ random_tls_extension_order = True
17
19
) as client:
18
20
response = await client.get(" https://tls.peet.ws/api/all" )
19
21
print (f " Detected TLS fingerprint: { response.json()[' tls' ][' ja3_hash' ]} " )
20
22
23
+
21
24
asyncio.run(main())
22
25
```
23
26
@@ -27,10 +30,10 @@ asyncio.run(main())
27
30
- ** Modern TLS Fingerprinting** : JA3, JA4, HTTP/2 fingerprints and TLS 1.3 support
28
31
- ** Client Profiles** : 50+ preconfigured clients (Chrome, Firefox, Safari, iOS, Android)
29
32
- ** Advanced Configuration** :
30
- - Custom TLS cipher suites & extensions
31
- - HTTP/2 and QUIC protocol support
32
- - Certificate pinning and compression
33
- - Proxy support (HTTP/S, SOCKS4/5)
33
+ - Custom TLS cipher suites & extensions
34
+ - HTTP/2 and QUIC protocol support
35
+ - Certificate pinning and compression
36
+ - Proxy support (HTTP/S, SOCKS4/5)
34
37
- ** Auto-Cookie Management** : Session persistence with configurable cookie jars
35
38
- ** Request Manipulation** : Header ordering, pseudo-header customization, and priority control
36
39
@@ -40,6 +43,38 @@ The fork was created due to the lack of updates in the original repository, whil
40
43
library [ tls-client] ( https://github.com/bogdanfinn/tls-client ) continues to evolve actively. This project aims to keep
41
44
up with the latest developments in the GoLang library and provide a modern, asynchronous interface for Python users.
42
45
46
+ ## Upcoming Breaking Changes 🚧
47
+
48
+ The library plans several breaking changes in future major releases to improve maintainability and reduce technical
49
+ debt:
50
+
51
+ ### Key Changes Planned:
52
+
53
+ 1 . ** Syntax Divergence from ` requests ` **
54
+ - The API will evolve to be less similar to ` requests ` to avoid dependency on its internal implementations.
55
+ - This may affect session/request patterns and method signatures.
56
+
57
+ 2 . ** Direct Import of ` CaseInsensitiveDict ` **
58
+ - The current custom ` CaseInsensitiveDict ` (copied from ` requests.structures ` ) will be replaced by direct imports
59
+ from ` requests ` or standard library alternatives.
60
+ - Users relying on ` async_tls_client.structures.CaseInsensitiveDict ` should prepare for import path changes.
61
+
62
+ 3 . ** Standard ` http.cookiejar.CookieJar ` Implementation**
63
+ - The custom ` RequestsCookieJar ` (borrowed from ` requests ` ) will be replaced with ` http.cookiejar.CookieJar ` for
64
+ cookie management.
65
+ - This may impact cookie handling APIs and persistence behavior.
66
+
67
+ 4 . ** Response Class Refactoring**
68
+ - The ` Response ` class may undergo structural changes to simplify implementation and align with modern Python
69
+ practices.
70
+ - Potential impacts include changes to attribute access, content handling, or JSON parsing methods.
71
+
72
+ ### Recommendations:
73
+
74
+ - Monitor changelogs for deprecation warnings in future minor releases
75
+ - Avoid direct reliance on internal modules like ` async_tls_client.structures ` or ` async_tls_client.cookies `
76
+ - Consider contributing feedback on the proposed changes through GitHub issues
77
+
43
78
## Installation 📦
44
79
45
80
``` bash
@@ -54,6 +89,7 @@ pip install async_tls_client
54
89
from async_tls_client import AsyncClient
55
90
import asyncio
56
91
92
+
57
93
async def main ():
58
94
async with AsyncClient(" chrome120" ) as client:
59
95
response = await client.get(
@@ -65,6 +101,7 @@ async def main():
65
101
print (f " Headers: { response.headers} " )
66
102
print (f " JSON: { response.json()} " )
67
103
104
+
68
105
asyncio.run(main())
69
106
```
70
107
@@ -101,17 +138,17 @@ client = AsyncClient(
101
138
102
139
Preconfigured client identifiers (https://github.com/bogdanfinn/tls-client/blob/master/profiles/profiles.go ):
103
140
104
- | Browser/Framework | Available Profiles |
105
- | -------------------------| ------------------------------------------------------------------------------------|
106
- | Chrome | chrome_103 - chrome_133 (including PSK variants: 116_PSK, 116_PSK_PQ, 131_PSK, 133_PSK) |
107
- | Firefox | firefox_102 - firefox_135 |
108
- | Safari (Desktop) | safari_15_6_1, safari_16_0, safari_ipad_15_6 |
109
- | Safari (iOS) | safari_ios_15_5 - safari_ios_18_0 |
110
- | Opera | opera_89 - opera_91 |
111
- | Android (OkHttp) | okhttp4_android_7 - okhttp4_android_13 |
112
- | iOS (Custom) | mms_ios (v1, v2, v3), mesh_ios (v1, v2), confirmed_ios, zalando_ios_mobile, nike_ios_mobile |
113
- | Android (Custom) | mesh_android (v1, v2), confirmed_android, zalando_android_mobile, nike_android_mobile |
114
- | Cloudflare | cloudscraper |
141
+ | Browser/Framework | Available Profiles |
142
+ | -------------------| --------- ------------------------------------------------------------------------------------|
143
+ | Chrome | chrome_103 - chrome_133 (including PSK variants: 116_PSK, 116_PSK_PQ, 131_PSK, 133_PSK) |
144
+ | Firefox | firefox_102 - firefox_135 |
145
+ | Safari (Desktop) | safari_15_6_1, safari_16_0, safari_ipad_15_6 |
146
+ | Safari (iOS) | safari_ios_15_5 - safari_ios_18_0 |
147
+ | Opera | opera_89 - opera_91 |
148
+ | Android (OkHttp) | okhttp4_android_7 - okhttp4_android_13 |
149
+ | iOS (Custom) | mms_ios (v1, v2, v3), mesh_ios (v1, v2), confirmed_ios, zalando_ios_mobile, nike_ios_mobile |
150
+ | Android (Custom) | mesh_android (v1, v2), confirmed_android, zalando_android_mobile, nike_android_mobile |
151
+ | Cloudflare | cloudscraper |
115
152
116
153
## Advanced Features 🔧
117
154
@@ -155,34 +192,37 @@ response = await client.get(
155
192
The client leverages Python's asyncio through three key strategies:
156
193
157
194
1 . ** Non-blocking I/O**
158
- - Network operations run in separate threads using ` asyncio.to_thread `
159
- - Go TLS client handles remain managed in background executors
195
+ - Network operations run in separate threads using ` asyncio.to_thread `
196
+ - Go TLS client handles remain managed in background executors
160
197
161
198
2 . ** Session Management**
162
- - ` AsyncClient ` context manager handles automatic cleanup
163
- - Connection pooling with automatic keep-alives
164
- - Cookie persistence across requests
199
+ - ` AsyncClient ` context manager handles automatic cleanup
200
+ - Connection pooling with automatic keep-alives
201
+ - Cookie persistence across requests
165
202
166
203
3 . ** Resource Optimization**
167
- - Zero-copy body handling for large responses
168
- - Lazy initialization of heavy resources
169
- - Automatic memory cleanup of Go pointers
204
+ - Zero-copy body handling for large responses
205
+ - Lazy initialization of heavy resources
206
+ - Automatic memory cleanup of Go pointers
170
207
171
208
## Packaging 📦
172
209
173
210
When using PyInstaller/PyArmor, include the shared library:
174
211
175
212
### Windows
213
+
176
214
``` bash
177
215
--add-binary ' async_tls_client/dependencies/tls-client-64.dll;async_tls_client/dependencies'
178
216
```
179
217
180
218
### Linux
219
+
181
220
``` bash
182
221
--add-binary ' async_tls_client/dependencies/tls-client-x86.so:async_tls_client/dependencies'
183
222
```
184
223
185
224
### macOS
225
+
186
226
``` bash
187
227
--add-binary ' async_tls_client/dependencies/tls-client-arm64.dylib:async_tls_client/dependencies'
188
228
```
0 commit comments