fastreq 3.0.0
High-performance async HTTP client built on niquests (default) and httpx (optional).
Features
- Two transports: niquests (default, required) and httpx (optional extra)
- HTTP/2 support via niquests/qh3 (always) and httpx+hyper (when h2 installed)
- Explicit proxy pools with health tracking, cooldown, round-robin rotation, and Webshare import — no free-proxy discovery
- Token-bucket rate limiting — rate token acquired before the concurrency slot
- Typed retry — only transient transport errors and configured retryable status codes (429, 500, 502, 503, 504); honors
Retry-After - User-agent rotation from a built-in list or custom list
- Cookie management with session-scoped, proxy-isolated storage
- Chunked streaming via callbacks in both transports
- Flexible response parsing — JSON, text, content, response object, or stream
- Keyed responses for dict-style result mapping
Installation
# Core library (niquests is the default and required transport)
pip install fastreq
# With HTTPX as an alternative transport
pip install fastreq[httpx]
# With HTTP/2 support for httpx (niquests supports HTTP/2 natively)
pip install fastreq[httpx,h2]
Quick Start
Sync Usage
from fastreq import fastreq
result = fastreq("https://api.github.com/repos/python/cpython")
print(result)
Async Usage
import asyncio
from fastreq import fastreq_async
async def main():
results = await fastreq_async([
"https://api.github.com/repos/python/cpython",
"https://api.github.com/repos/python/cpython/issues",
], concurrency=5)
return results
results = asyncio.run(main())
Context Manager
from fastreq import FastRequests
async def main():
async with FastRequests(concurrency=5) as client:
result = await client.request("https://api.github.com/repos/python/cpython")
return result
Streaming
from fastreq import FastRequests, ReturnType
async def main():
async with FastRequests() as client:
await client.request(
"https://example.com/large-file.zip",
return_type=ReturnType.STREAM,
stream_callback=lambda chunk: print(f"Got {len(chunk)} bytes"),
)
Explicit Proxy Rotation
from fastreq import FastRequests
# Provide a proxy list directly
proxies = [
"http://user:pass@proxy1:8080",
"http://user:pass@proxy2:8080",
]
async with FastRequests(
proxies=proxies,
random_proxy=True,
proxy_selection="round_robin",
proxy_cooldown=60.0,
) as client:
result = await client.request("https://api.example.com/data")
You can also set proxies via the FASTREQ_PROXIES environment variable (comma-separated) or import from a Webshare text file via webshare_file=.
Backend Selection
| Backend | Status | HTTP/2 | Install |
|---|---|---|---|
| niquests | Default | Native | pip install fastreq |
| httpx | Optional | h2 dep | pip install fastreq[httpx] |
| curl_cffi | Optional | Native | pip install fastreq[curl] |
backend="auto" (the default) always selects niquests. To use another backend explicitly:
FastRequests(backend="httpx")
Browser impersonation (curl_cffi backend)
The curl_cffi backend can replicate a real browser's TLS fingerprint
(JA3/JA4), HTTP/2 settings, and default headers via the impersonate
parameter. This defeats bot detection that blocks plain HTTP clients:
async with FastRequests(backend="curl_cffi", impersonate="chrome") as client:
result = await client.request("https://example.com/bot-protected")
# or a random recent browser target per client
FastRequests(backend="curl_cffi", impersonate="random")
When impersonate is set, user-agent rotation is disabled automatically —
curl_cffi supplies the browser-matching User-Agent itself. One session is
kept per proxy route, so cookies stay isolated between proxies.
Migration from 2.x to 3.0
Breaking changes
- Removed backends:
aiohttpandrequeststransports are gone. Useniquests(default) orhttpx. - Removed free proxies: The library no longer discovers or fetches free proxies. Provide explicit proxies via
proxies=,FASTREQ_PROXIES, orwebshare_file=. - Canonical name: The project is now
fastreq(previouslyparallel-requests).ParallelRequestsremains as a Python alias for backward compatibility.
What to do
- If you used
backend="aiohttp"orbackend="requests", switch to the default niquests transport or installfastreq[httpx]and usebackend="httpx". - If you used
free_proxies=True, remove it and provide an explicit proxy list or Webshare source instead. - If you imported
ParallelRequests, it still works as an alias — but the canonical name isFastRequests.
Proxy Policy
fastreq 3.0 does not fetch free proxies. Proxy sources in priority order:
proxies=constructor argument (list of URLs)FASTREQ_PROXIESenvironment variable (comma-separated)webshare_file=path to a Webshare plain-text proxy file (ip:port:user:passwordper line)
Failed proxies enter a configurable cooldown. Successful requests clear the cooldown. Selection strategies: round_robin (default) or random.
Documentation
Development
This project uses uv for dependency management and packaging.
# Install all dependencies
uv sync --all-groups
# Run quality gates
uv run ruff format --check .
uv run ruff check .
uv run ty check src
uv run pytest -q
# Build
uv build
License
MIT License — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastreq-3.1.1.tar.gz.
File metadata
- Download URL: fastreq-3.1.1.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30f1dfcb59b9405caa6cded4d70a43923795e7c6e59a43df32907ae032539329
|
|
| MD5 |
4b94066bbb7d754be3bfbe404b8a7f0c
|
|
| BLAKE2b-256 |
8368a5967d3e0267142127e2f39b204780284cc6fc23d94f02376e6d630ca865
|
File details
Details for the file fastreq-3.1.1-py3-none-any.whl.
File metadata
- Download URL: fastreq-3.1.1-py3-none-any.whl
- Upload date:
- Size: 34.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
046070654051a4ac4a8569a3e928b78a18b80cfd7f4743f16703a86c9b71bb4d
|
|
| MD5 |
88c6ac6e91f79a85bac33a138d16dad1
|
|
| BLAKE2b-256 |
71f332628ce0103c4f429bd15c112270ed85bdae1019bbea5773b204987a3c15
|