Skip to main content

Python bindings for web-transport-quinn

Project description

web-transport

PyPI License: MIT

Python bindings for web-transport-quinn — a pure-Rust WebTransport library built on QUIC.

Features

  • Server and client — one session per connection, no HTTP/3 pooling complexity
  • Streams — bidirectional and unidirectional, with backpressure
  • Datagrams — unreliable, low-latency messaging
  • Certificate pinning — connect to self-signed servers by hash
  • Async-native — built for asyncio, works with async with and async for
  • Fast — Rust core compiled to a native extension via PyO3

Installation

pip install web-transport-quinn

Requires Python 3.12+. Prebuilt wheels are available for Linux, macOS, and Windows.

Quick start: Echo server

import asyncio
import web_transport

async def main():
    cert, key = web_transport.generate_self_signed(["localhost"])

    async with web_transport.Server(
        certificate_chain=[cert],
        private_key=key,
        bind="[::]:4433",
    ) as server:
        print(f"Listening on {server.local_addr}")
        print(f"Certificate hash: {web_transport.certificate_hash(cert).hex()}")

        async for request in server:
            session = await request.accept()
            asyncio.create_task(handle(session))

async def handle(session: web_transport.Session):
    async with session:
        send, recv = await session.accept_bi()
        async with send:
            data = await recv.read()
            await send.write(data)

asyncio.run(main())

Quick start: Client

import asyncio
import web_transport

async def main():
    async with web_transport.Client(no_cert_verification=True) as client:
        session = await client.connect("https://localhost:4433")

        async with session:
            send, recv = await session.open_bi()
            async with send:
                await send.write(b"Hello, WebTransport!")
            response = await recv.read()
            print(response)

asyncio.run(main())

API overview

Name Description
Server Listens for incoming WebTransport sessions
SessionRequest Inspect and accept/reject incoming sessions
Client Opens outgoing WebTransport sessions
Session Established session — open streams, send datagrams
SendStream Write to a QUIC stream
RecvStream Read from a QUIC stream
generate_self_signed() Create a self-signed certificate and private key (DER bytes)
certificate_hash() SHA-256 fingerprint of a DER-encoded certificate

Server and Client accept DER-encoded bytes for certificates and keys, so you can use any TLS library (e.g. cryptography) to generate or load them.

All exceptions inherit from web_transport.WebTransportError. See the type stubs for the full API reference.

Certificate pinning

Connect to servers with self-signed certificates by pinning their SHA-256 hash:

cert_hash = web_transport.certificate_hash(cert)  # or bytes.fromhex("ab12cd34...")

async with web_transport.Client(
    server_certificate_hashes=[cert_hash],
) as client:
    session = await client.connect("https://localhost:4433")

Datagrams

Send and receive unreliable datagrams over an established session:

await session.send_datagram(b"ping")
data = await session.receive_datagram()

The maximum payload size is available via session.max_datagram_size.

Development

See CLAUDE.md for full development conventions and tooling.

# Install dependencies
uv sync

# Build and test
uv run maturin develop
uv run pytest

# Lint and format
uv run ruff format .
uv run ruff check .
cargo fmt
cargo clippy -- -D warnings

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

web_transport_quinn-0.1.0.tar.gz (81.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

web_transport_quinn-0.1.0-cp313-cp313-manylinux_2_28_aarch64.whl (2.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

web_transport_quinn-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

web_transport_quinn-0.1.0-cp312-cp312-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.12Windows x86-64

web_transport_quinn-0.1.0-cp312-cp312-manylinux_2_28_aarch64.whl (2.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

web_transport_quinn-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

web_transport_quinn-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

web_transport_quinn-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file web_transport_quinn-0.1.0.tar.gz.

File metadata

  • Download URL: web_transport_quinn-0.1.0.tar.gz
  • Upload date:
  • Size: 81.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for web_transport_quinn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a965134b074e94ad503eab2ed1ffd784ec962136509ceb67e30e5e70705e47b0
MD5 c952967a7c640a175797396e6b598eef
BLAKE2b-256 10081771140817fda2dca0859cab6f97d41badfd693c62e91a90983a8542d1cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_transport_quinn-0.1.0.tar.gz:

Publisher: release.yml on ai-and-i/web-transport-quinn-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file web_transport_quinn-0.1.0-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for web_transport_quinn-0.1.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fb00178f2cdd2bc0d3a00923398577496c75b7a2d5a63c41e68fcaa9a5f1d3e6
MD5 081c4c01c099b514c5892d2bd722f074
BLAKE2b-256 d197da8593856f6cbf4f9ac00ab2248e0010ed3f771072740a4ebf5e2b6d7207

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_transport_quinn-0.1.0-cp313-cp313-manylinux_2_28_aarch64.whl:

Publisher: release.yml on ai-and-i/web-transport-quinn-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file web_transport_quinn-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for web_transport_quinn-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 137079a372774de9ea50af2bdcbbe082650dd67bf4abb369553942b76d6b638c
MD5 690bad8a78303a4310ce8dd547548aab
BLAKE2b-256 1bb265db1dba85f18ef8ae2ff502c3887d462b0780209acf1e7e2456ec03d4e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_transport_quinn-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on ai-and-i/web-transport-quinn-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file web_transport_quinn-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for web_transport_quinn-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fc9e732c836d8971e412fa86b7f630934f8640eb92b0dee928cae2cbe935b011
MD5 eddfabe7fd3e376408f3ca31b6f7e3dc
BLAKE2b-256 09d3066691862e2e20ebb0ffd37970d709e4b885dc322050264b948f45d9f971

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_transport_quinn-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on ai-and-i/web-transport-quinn-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file web_transport_quinn-0.1.0-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for web_transport_quinn-0.1.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7c431d27ef86cd2436859156593889f1d9b84ef09782e5032363dce29fc88e3d
MD5 eea8c4ad07f1b8183527e95f356456ca
BLAKE2b-256 edc4fe1964ff6fe964ae47b887629c382393a023715c5264ddc746e8ca5e0e62

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_transport_quinn-0.1.0-cp312-cp312-manylinux_2_28_aarch64.whl:

Publisher: release.yml on ai-and-i/web-transport-quinn-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file web_transport_quinn-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for web_transport_quinn-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 141f9a692756655f20576f52348a5d3ef910e6e7ac78d3a931a214c7cb318df0
MD5 13fdedaa8670f2cffdc83ca1e2a725e6
BLAKE2b-256 5b62be63839df46b2ef8a0324e64872526df9b6c11a79d60a76e2d69b1e9d056

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_transport_quinn-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on ai-and-i/web-transport-quinn-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file web_transport_quinn-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for web_transport_quinn-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8847e69c808e9a16b2e15c06fd5a87e18a5a6f26ef90c1ee8d1fb6454d191398
MD5 da011bbf7aaae109765f70c04b4b06a3
BLAKE2b-256 8979ad18b072005b4607a4585b9ca210965b9dec65902b0b63a855c70f91b9f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_transport_quinn-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on ai-and-i/web-transport-quinn-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file web_transport_quinn-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for web_transport_quinn-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 eccdbcf0019af442821a541b15cd7218abd5e67dc8e4acad68713eb31ba52195
MD5 245ed0fda690051828cb3e8a746897dc
BLAKE2b-256 3e05d1910f5bf8b32193ac24739c105dcc242d73aa2b39f6114af32bcea5282f

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_transport_quinn-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: release.yml on ai-and-i/web-transport-quinn-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page