PyQwest

0.4.1 · active · verified Tue Apr 14

PyQwest is a modern Python HTTP client built on the high-performance Rust library `reqwest`. It offers support for advanced HTTP features, including bidirectional streaming, HTTP/2, and HTTP/3. It provides both asynchronous and synchronous client interfaces and aims for a fully-typed, Pythonic API. The current version is 0.4.1. Releases are made on an as-needed basis, often to incorporate updates from the underlying `reqwest` library or to add new features.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic GET requests using both the asynchronous `Client` and synchronous `SyncClient`.

import asyncio
from pyqwest import Client, SyncClient

async def async_example():
    client = Client()
    response = await client.get("https://httpbin.org/get")
    print(f"Async Response Status: {response.status}")
    print(f"Async Response Body Length: {len(await response.content())}")

def sync_example():
    client = SyncClient()
    response = client.get("https://httpbin.org/get")
    print(f"Sync Response Status: {response.status}")
    print(f"Sync Response Body Length: {len(response.content())}")

if __name__ == "__main__":
    print("Running async example...")
    asyncio.run(async_example())
    print("\nRunning sync example...")
    sync_example()

view raw JSON →