async-requests-tls
Async Python HTTP/1.1 client whose TLS ClientHello is byte-for-byte
identical to what the requests
library sends — same JA3, same JA4. Useful when a site fingerprints the TLS
handshake and rejects modern async clients (httpx, niquests, …) while
happily accepting plain requests.
The trick: requests builds its ssl.SSLContext through
urllib3.util.ssl_.create_urllib3_context(). So do we. The context is then
fed into asyncio.open_connection(..., ssl=ctx), so both stacks drive the
same OpenSSL build with the same cipher list, options, ALPN, curves, and
sigalgs.
Install
pip install async-requests-tls
# or with uv:
uv add async-requests-tls
The PyPI distribution name is
async-requests-tlsbut the Python import name isasync_requests_tls.
For development from a clone of this repo:
pip install -e .[dev]
# or:
uv sync --extra dev
Requires Python 3.13+ and urllib3>=2.0.
Quickstart
import asyncio
from async_requests_tls import AsyncSession
async def main():
async with AsyncSession() as s:
# GET
r = await s.get("https://httpbin.org/get", params={"hello": "world"})
print(r.status_code, r.json())
# POST with JSON
r = await s.post("https://httpbin.org/post", json={"x": 1})
print(r.json())
# Session-wide base_url, headers, and cookie jar
async with AsyncSession(
base_url="https://api.example.com",
headers={"X-Token": "secret"},
) as api:
await api.get("/users") # GET https://api.example.com/users
await api.post("/orders", data={"sku": "abc"})
asyncio.run(main())
AsyncSession supports get / post / put / patch / delete /
head / options, with a requests-style API: params, headers,
data, json, cookies, allow_redirects. Responses expose
status_code, headers, content, text, json(), ok, and
cookies.
Caveats
- HTTP/1.1 only. ALPN defaults to
["http/1.1"]so the server never upgrades us to h2. If you passalpn=alpn_protocols_like_urllib3()(to match the exact ALPN bytesrequestssends when urllib3-future is installed) and the server picksh2, the session raisesNotImplementedError— the TLS handshake still matched, the wire protocol did not. - No connection pooling, no proxies, no streaming, no multipart, no HTTP/2. This is a small, focused library.
- JA3 parity ≠ detection-evasion parity. Modern detectors also look at HTTP/2 SETTINGS frames, header order (JA4_H), and Akamai-style timing. This library only matches the TLS layer.
Testing
uv run pytest # or: pytest
All tests are unit tests — they don't open real sockets. The wire-level
tests drive asyncio.StreamReader with canned bytes; the session tests
patch _send_once with a fake.
Public API
from async_requests_tls import (
AsyncSession,
Response,
build_ssl_context, # if you want the SSLContext directly
alpn_protocols_like_urllib3, # exact ALPN list urllib3 would send
)
License
MIT — see LICENSE.
Metadata
Release files for async-requests-tls 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| async_requests_tls-0.1.0.tar.gz | 16.9 kB | Without provenance | Details for async_requests_tls-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| async_requests_tls-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for async_requests_tls-0.1.0-py3-none-any.whl |
Total release size: 28.5 kB
Release files / async_requests_tls-0.1.0.tar.gz
| Download URL | async_requests_tls-0.1.0.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b248cf0f9aa726d7a92173eb585cb467ec561c252088a6099516a544023754b1
|
|
BLAKE2b-256 checksum How to use checksums |
02b644fd89894889e9d4edb607bd8d342eb29ad9610cceb1168b0e0853b4d2a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Release files / async_requests_tls-0.1.0-py3-none-any.whl
| Download URL | async_requests_tls-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
accd43546258a371227a1a313fa74ebb5fb60735f131b0781b80463d7c664dba
|
|
BLAKE2b-256 checksum How to use checksums |
a4a1ed4d7aeb7bf86d27e24ce6e6eccc6a1ee9fd042cd4dffee68ab6ff05ebb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Security for async-requests-tls 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.