Aiosonic

0.31.1 · active · verified Sat Apr 11

Aiosonic is a lightweight and very fast asynchronous HTTP/WebSocket client for Python, built on `asyncio`. It supports HTTP/1.1 and HTTP/2, offering features like connection pooling, multipart file uploads, chunked transfer handling, automatic decompression, and redirect following. Version 0.31.1 supports Python >= 3.10 and continues to evolve with a focus on performance and robust network interactions, including recent improvements for HTTP/2.

Warnings

Install

Imports

Quickstart

Initializes an `HTTPClient` to perform a basic GET request to `httpbin.org/get` and prints the status code and response content. It demonstrates the core asynchronous request pattern and proper client cleanup.

import asyncio
import aiosonic

async def main():
    client = aiosonic.HTTPClient()
    try:
        response = await client.get('https://httpbin.org/get')
        assert response.status_code == 200
        print(f"Status Code: {response.status_code}")
        print(f"Response content: {await response.text()}")
    finally:
        # Ensure client is closed to release resources
        await client.wait_requests_done()

if __name__ == '__main__':
    asyncio.run(main())

view raw JSON →