fasttransport
Install
pip install fasttransport
Why
Every small API wrapper needs the same plumbing: headers merged into each request, responses decoded by content type, errors that carry the response body, and SSE parsing for streams. Most wrappers also repeat the same mistake. They create one httpx client at startup and keep it, which pins its pooled connections to the event loop that created them. Code that later runs under a different loop, common in tests and background tasks, then fails with confusing connection errors.
fasttransport is that plumbing written once, on httpx2. Each request gets a fresh client and nothing is tied to a loop. Pass client= to manage a persistent client yourself. fastspec builds its spec-driven clients on these transports, ghapi its GitHub client, and solveit its gateway clients.
Get started
SyncTransport.request executes a call and returns the decoded body: JSON arrives as a dict, text as text, and anything else as bytes. HTTP errors raise with the response body included in the message.
from fasttransport.core import *
SyncTransport().request('GET', 'https://jsonplaceholder.typicode.com/todos/1')
AsyncTransport is the same, awaited. It also has stream, an async generator that parses SSE events into JSON dicts. The core page streams a chat completion with it.
await AsyncTransport().request('GET', 'https://jsonplaceholder.typicode.com/users/1')
A small REST client is a base URL plus verbs. HttpCli verbs take a path relative to the base, kwargs become the payload (query params on get and delete, the JSON body otherwise), and decoded bodies come back:
cli = HttpCli('https://jsonplaceholder.typicode.com')
cli.get('todos/1')
cli.post('posts', title='hi')
AsyncHttpCli is the async twin. Its verbs return awaitables:
acli = AsyncHttpCli('https://jsonplaceholder.typicode.com')
await acli.get('todos/1')
The core page documents the rest with runnable examples: SSE streaming, error enrichment, multipart uploads, and managing your own client.
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 fasttransport-0.0.1.tar.gz.
File metadata
- Download URL: fasttransport-0.0.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c88fc989fb333efb4d3221379178600bac2f0c7156ad6f8d614ba7eafad39e3a
|
|
| MD5 |
cd7790147a2a3fa5a30329752a447eeb
|
|
| BLAKE2b-256 |
92cadefba9b5466caafcdc069c74244c1fb27255e7c8574de523c99dec053551
|
File details
Details for the file fasttransport-0.0.1-py3-none-any.whl.
File metadata
- Download URL: fasttransport-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab131ac912214e1f39cba0d8fcdbf3ed26a455abb23751f5f6008c2166860d5d
|
|
| MD5 |
7a16cf1a716470dce775798e8547c415
|
|
| BLAKE2b-256 |
45684f69754497b13ba216e11f13d9e3d19ba9aa42c29443ddc4ba948531774d
|