skillfed

treq

High-level Twisted HTTP Client API

treq v26.7.0 299.5K downloads/30d#7,858 on PyPI604
Permissive license MIT Active released

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 treq

uv

uv add treq

poetry

poetry add treq

Installing 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

Development Status :: 5 - Production/StableFramework :: TwistedIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

twisted http clientasync http requeststwisted web clientasynchronous http librarytwisted http apirequests-like twistedtwisted http agent wrapper
twistedasync-httpevent-loop

More WWW/HTTP packages