Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

webtransport-py

PyPI image License Actions status Discord

About Shiguredo's open source software

We will not respond to PRs or issues that have not been discussed on Discord. Also, Discord is only available in Japanese.

Please read https://github.com/shiguredo/oss/blob/master/README.en.md before use.

時雨堂のオープンソースソフトウェアについて

利用前に https://github.com/shiguredo/oss をお読みください。

webtransport-py について

webtransport-py は Sans I/O アーキテクチャを採用した WebTransport の Python ライブラリです。WebTransport over HTTP/3 と WebTransport over HTTP/2 の両方に対応しています。

また、WebTransport だけでなく QUIC、HTTP/3、HTTP/2 を単体のプロトコルとしても利用できます。asyncio、スレッド、独自のイベントループなど、任意の I/O フレームワークと組み合わせて利用できます。

特徴

  • Sans I/O アーキテクチャ
    • I/O 処理をライブラリ外部で制御可能
    • 任意のイベントループやフレームワークと統合可能
    • Sans I/O
  • 二層 API 設計
    • Sans I/O API: プロトコル処理のみを提供する低レベル API
    • asyncio API: すぐに使える高レベルなクライアント/サーバー実装
  • QUIC
    • Sans I/O API と asyncio API の両方を提供
    • 双方向/単方向ストリーム
    • QUIC DATAGRAM
    • 0-RTT / Session Resumption
    • 証明書のカスタム検証
    • Connection Migration
    • ngtcp2 を採用
  • HTTP/3
    • Sans I/O API と asyncio API の両方を提供
    • nghttp3 を採用
  • HTTP/2
    • Sans I/O API と asyncio API の両方を提供
    • nghttp2 を採用
  • WebTransport over HTTP/3
    • Sans I/O API と asyncio API の両方を提供
  • WebTransport over HTTP/2
    • Sans I/O API と asyncio API の両方を提供
  • Python Free-Threading 対応
  • クロスプラットフォーム対応
    • Ubuntu x86_64 / arm64
    • macOS arm64

インストール

uv add webtransport-py

使い方

WebTransport over HTTP/3

サーバー

import asyncio

from webtransport import h3


async def main() -> None:
    server = h3.Server(
        host="0.0.0.0",
        port=4433,
        certfile="cert.pem",
        keyfile="key.pem",
    )

    async def on_session_ready(session_id: int, addr: tuple[str, int]) -> None:
        print(f"セッション確立: {session_id} from {addr}")

    async def on_stream_data(
        session_id: int,
        stream_id: int,
        data: bytes,
        addr: tuple[str, int],
    ) -> None:
        print(f"データ受信: {data}")
        # エコーバック
        await server.send_stream_data(addr, stream_id, data)

    async def on_datagram(session_id: int, data: bytes, addr: tuple[str, int]) -> None:
        print(f"データグラム受信: {data}")
        # エコーバック
        await server.send_datagram(addr, session_id, data)

    server.on_session_ready(on_session_ready)
    server.on_stream_data(on_stream_data)
    server.on_datagram(on_datagram)

    async with server:
        print(f"サーバー開始: {server.host}:{server.actual_port}")
        await server.run()


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

クライアント

import asyncio

from webtransport import h3


async def main() -> None:
    client = h3.Client(
        url="https://localhost:4433/webtransport",
        verify_peer=False,
    )

    async def on_stream_data(stream_id: int, data: bytes) -> None:
        print(f"データ受信: {data}")

    async def on_datagram(data: bytes) -> None:
        print(f"データグラム受信: {data}")

    client.on_stream_data(on_stream_data)
    client.on_datagram(on_datagram)

    if not await client.connect():
        print("接続失敗")
        return

    # ストリームでデータ送信
    stream_id = await client.open_stream()
    await client.send_stream_data(stream_id, b"Hello via stream!")

    # データグラムでデータ送信
    await client.send_datagram(b"Hello via datagram!")

    try:
        await asyncio.wait_for(client.run(), timeout=5.0)
    except TimeoutError:
        pass

    await client.close()


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

WebTransport over HTTP/2

サーバー

import asyncio

from webtransport import h2


async def main() -> None:
    server = h2.Server(
        host="0.0.0.0",
        port=8443,
        certfile="cert.pem",
        keyfile="key.pem",
    )

    async def on_session_ready(session_writer: h2.SessionWriter) -> None:
        print(f"セッション確立: {session_writer.session_id}")

    async def on_stream_data(
        stream_id: int,
        data: bytes,
        session_writer: h2.SessionWriter,
    ) -> None:
        print(f"データ受信: {data}")
        # エコーバック
        await session_writer.send_stream_data(stream_id, data)

    async def on_datagram(data: bytes, session_writer: h2.SessionWriter) -> None:
        print(f"データグラム受信: {data}")
        # エコーバック
        await session_writer.send_datagram(data)

    server.on_session_ready(on_session_ready)
    server.on_stream_data(on_stream_data)
    server.on_datagram(on_datagram)

    async with server:
        print(f"サーバー開始: {server.host}:{server.actual_port}")
        await server.run()


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

クライアント

import asyncio

from webtransport import h2


async def main() -> None:
    client = h2.Client(
        url="https://localhost:8443/webtransport",
        verify_peer=False,
    )

    async def on_stream_data(stream_id: int, data: bytes) -> None:
        print(f"データ受信: {data}")

    async def on_datagram(data: bytes) -> None:
        print(f"データグラム受信: {data}")

    client.on_stream_data(on_stream_data)
    client.on_datagram(on_datagram)

    if not await client.connect():
        print("接続失敗")
        return

    # ストリームでデータ送信
    stream_id = await client.open_stream()
    await client.send_stream_data(stream_id, b"Hello via stream!")

    # データグラムでデータ送信
    await client.send_datagram(b"Hello via datagram!")

    try:
        await asyncio.wait_for(client.run(), timeout=5.0)
    except TimeoutError:
        pass

    await client.close()


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

QUIC

サーバー

import asyncio

from webtransport import quic


async def main() -> None:
    server = quic.Server(
        host="0.0.0.0",
        port=4433,
        certfile="cert.pem",
        keyfile="key.pem",
    )

    async def on_handshake_completed(addr: tuple[str, int]) -> None:
        print(f"ハンドシェイク完了: {addr}")

    async def on_stream_data(
        stream_id: int,
        data: bytes,
        fin: bool,
        addr: tuple[str, int],
    ) -> None:
        print(f"データ受信: {data}")
        # エコーバック
        await server.send_stream_data(addr, stream_id, data, fin)

    server.on_handshake_completed(on_handshake_completed)
    server.on_stream_data(on_stream_data)

    async with server:
        print(f"サーバー開始: {server.host}:{server.actual_port}")
        await server.run()


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

クライアント

import asyncio

from webtransport import quic


async def main() -> None:
    client = quic.Client(
        host="localhost",
        port=4433,
        verify_peer=False,
    )

    if not await client.connect():
        print("接続失敗")
        return

    # 双方向ストリームを開いてデータ送信 (FIN でストリームを閉じる)
    stream_id = await client.open_stream(bidirectional=True)
    await client.send_stream_data(stream_id, b"Hello, QUIC!", fin=True)

    # サーバーからのエコーを FIN まで受信する
    try:
        data, _ = await client.recv_stream_data(stream_id, timeout=5.0)
        print(f"データ受信: {data}")
    except TimeoutError:
        print("受信タイムアウト")

    await client.close()


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

Python

  • 3.14
  • 3.14t

プラットフォーム

  • Ubuntu 24.04 LTS x86_64
  • Ubuntu 24.04 LTS arm64
  • macOS 26 arm64

リリースビルド

make wheel

開発ビルド

make develop

テスト

uv sync
make test

サンプル

examples/ ディレクトリにサンプルコードがあります。

第三者ライセンス

本プロジェクトは ngtcp2 / nghttp3 / nghttp2 / AWS-LC を静的リンクしています。各ライセンス全文は THIRD_PARTY_LICENSES.md を参照してください。

ライセンス

Apache License 2.0

Copyright 2026 Shiguredo Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Metadata

Release files for webtransport-py 2026.1.0.dev16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for webtransport-py 2026.1.0.dev16
File
webtransport_py-2026.1.0.dev16-cp314-cp314t-manylinux_2_39_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.39+ x86-64 Details
webtransport_py-2026.1.0.dev16-cp314-cp314t-manylinux_2_39_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.39+ ARM64 Details
webtransport_py-2026.1.0.dev16-cp314-cp314t-macosx_26_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 26.0+ ARM64 Details
webtransport_py-2026.1.0.dev16-cp314-cp314-manylinux_2_39_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.39+ x86-64 Details
webtransport_py-2026.1.0.dev16-cp314-cp314-manylinux_2_39_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.39+ ARM64 Details
webtransport_py-2026.1.0.dev16-cp314-cp314-macosx_26_0_arm64.whl CPython 3.14 CPython 3.14 macOS 26.0+ ARM64 Details

Total release size: 12.3 MB

Release files / webtransport_py-2026.1.0.dev16-cp314-cp314t-manylinux_2_39_x86_64.whl

Download URL webtransport_py-2026.1.0.dev16-cp314-cp314t-manylinux_2_39_x86_64.whl
Size 2.2 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
caab58f257499eb8197eb9687c2d1117b9c67e103ec3528369e3204182b40ddc
BLAKE2b-256 checksum
How to use checksums
b527f3bdb5203942d74719e2745155ea5df3d4b0be14f63e4f6014501961ea0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

Release files / webtransport_py-2026.1.0.dev16-cp314-cp314t-manylinux_2_39_aarch64.whl

Download URL webtransport_py-2026.1.0.dev16-cp314-cp314t-manylinux_2_39_aarch64.whl
Size 2.1 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.39+ ARM64
SHA-256 checksum
How to use checksums
8525cd7b57e30dcc9b02b2dde62ad393833b43e82928837d96272cbbf6f833e0
BLAKE2b-256 checksum
How to use checksums
1758e498cf8cfaaac6aa60c1c3cfe95fc1c810545afc92ea8b528f469ab3af7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

Release files / webtransport_py-2026.1.0.dev16-cp314-cp314t-macosx_26_0_arm64.whl

Download URL webtransport_py-2026.1.0.dev16-cp314-cp314t-macosx_26_0_arm64.whl
Size 1.9 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
31d57bdf90363329a950fe36224174169a5490542b3ba31fd199a7370a3a4da1
BLAKE2b-256 checksum
How to use checksums
a6640ba717bedb931d2513c98cde8ba116c3ccb56503dfd21b28365d89f7c0a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

Release files / webtransport_py-2026.1.0.dev16-cp314-cp314-manylinux_2_39_x86_64.whl

Download URL webtransport_py-2026.1.0.dev16-cp314-cp314-manylinux_2_39_x86_64.whl
Size 2.2 MB
Tags CPython 3.14 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
2620ce29e9d783768221e9697c7579db15d0019d5adfe93e9d34447ea7171a47
BLAKE2b-256 checksum
How to use checksums
6cd9a6565ccaf1e172de2b9221a1ee1c2b751056cd78c5616d1075dddd555716
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

Release files / webtransport_py-2026.1.0.dev16-cp314-cp314-manylinux_2_39_aarch64.whl

Download URL webtransport_py-2026.1.0.dev16-cp314-cp314-manylinux_2_39_aarch64.whl
Size 2.1 MB
Tags CPython 3.14 Linux glibc 2.39+ ARM64
SHA-256 checksum
How to use checksums
56a57b2b8f87f37004eca12917a799fcff1953ab1a85822eb7b78ff4494ab92b
BLAKE2b-256 checksum
How to use checksums
57547676d7e574bf5bb9d9fd278915df7875f72fd012bd812a27729a4eedbbd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

Release files / webtransport_py-2026.1.0.dev16-cp314-cp314-macosx_26_0_arm64.whl

Download URL webtransport_py-2026.1.0.dev16-cp314-cp314-macosx_26_0_arm64.whl
Size 1.9 MB
Tags CPython 3.14 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
b2447f0a7390b6a9e95cb836adc18c9531d973377188439907cb167503e5b606
BLAKE2b-256 checksum
How to use checksums
51436afe8442e20d0fa92ce64c1df12330252557720d85c982661d85f63e15ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page