treq
High-level Twisted HTTP Client API
What it is and what it does
treq bridges the gap between Twisted's low-level HTTP machinery and the simple, intuitive API style of the requests library. It wraps Twisted's Agent with a higher-level interface that lets you make HTTP calls using familiar method names like get(), post(), and put() while staying within Twisted's asynchronous event loop. This makes it easier to write HTTP-heavy Twisted applications without wrestling with Agent's lower-level abstractions.
The library is built on six runtime dependencies: attrs, hyperlink, incremental, multipart, twisted, and typing-extensions. It's designed for developers already committed to Twisted who want a more ergonomic way to handle HTTP requests in their async code. The package is actively maintained, supports modern Python versions (3.9 through 3.14), and runs on both CPython and PyPy.
Use it for:
- Making HTTP requests from within a Twisted application without dropping to low-level Agent APIs
- Building web scrapers or API clients that need to integrate with existing Twisted services
- Handling multipart form uploads in async Twisted code using the multipart dependency
- Writing integration tests for Twisted services that need to make outbound HTTP calls
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
treq is a high-level HTTP client library for Twisted that provides a requests-like API for making asynchronous HTTP calls within Twisted applications.
Yes, if you are already using Twisted and need to make HTTP requests. treq significantly reduces boilerplate compared to raw Agent usage and has no known vulnerabilities. The MIT license is unrestrictive. If you are not already committed to Twisted, consider whether a non-Twisted async HTTP library (like httpx or aiohttp) might be simpler for your use case.
Install
treq on PyPI
pip
pip install trequv
uv add treqpoetry
poetry add treqInstalling treq
Before you install
Low install friction with six runtime dependencies. Actively maintained with a recent release 43 days ago and last commit on 2026-08-08. Supports Python 3.9 through 3.14 and runs on both CPython and PyPy.
License in practice
MIT license (permissive) means you can use, modify, and distribute treq freely in commercial and private projects with minimal restrictions.
Quickstart
import treq
from twisted.internet.task import react
async def main(reactor):
response = await treq.get("https://github.com")
print(response.code)
body = await response.text()
return body
react(main)
Requires Twisted to be installed and running; treq is designed for use within Twisted's reactor-based event loop, not standalone synchronous code.
Verify before relying
- Whether treq's API surface and feature parity with requests are sufficient for your specific HTTP use case
- Performance characteristics compared to other async HTTP libraries in the Twisted ecosystem
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — attrs, hyperlink, incremental, multipart, twisted, typing-extensions |
| Maintenance | actively maintained — 43 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 299,531/month — #7,858 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: treq-26.7.0-py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
TwistedTwisted is an event-driven networking framework…
permissive · top 5,000 on PyPI
pytest-twistedA pytest plugin that enables testing of…
permissive · top 15,000 on PyPI
prometheus-asyncAdds async/await support to Prometheus metrics…
permissive · top 15,000 on PyPI
localstack-twistedA LocalStack-optimized distribution of Twisted…
permissive · top 15,000 on PyPI
txtorcontxtorcon is a client library for controlling…
permissive · top 15,000 on PyPI
crochetCrochet lets you call Twisted asynchronous code…
permissive · top 15,000 on PyPI
txaiotxaio provides a compatibility layer that lets…
permissive · top 5,000 on PyPI
fetch-useRoutes HTTP requests through Browser-Use's…
permissive · top 5,000 on PyPI
pytest-tornadoA pytest plugin that provides fixtures and…
permissive · top 15,000 on PyPI
ldaptorLdaptor is a pure-Python LDAP client library…
permissive · top 5,000 on PyPI