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

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
    • 証明書のカスタム検証
    • 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 対応
  • クロスプラットフォーム対応
    • macOS arm64
    • Ubuntu x86_64 / arm64
    • Windows x86_64

インストール

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())

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,
    )

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

    client.on_stream_data(on_stream_data)

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

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

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

    await client.close()


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

Python

  • 3.14
  • 3.14t

プラットフォーム

  • macOS 26 arm64
  • macOS 15 arm64
  • Ubuntu 24.04 LTS x86_64
  • Ubuntu 24.04 LTS arm64
  • Ubuntu 22.04 LTS x86_64
  • Ubuntu 22.04 LTS arm64
  • Windows 2025 x86_64
  • Windows 11 x86_64

リリースビルド

make wheel

開発ビルド

make develop

テスト

uv sync
make test

サンプル

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

ngtcp2 ライセンス

https://github.com/ngtcp2/ngtcp2/blob/main/COPYING

The MIT License

Copyright (c) 2016 ngtcp2 contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

nghttp3 ライセンス

https://github.com/ngtcp2/nghttp3/blob/main/COPYING

The MIT License

Copyright (c) 2019 nghttp3 contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

nghttp2 ライセンス

https://github.com/nghttp2/nghttp2/blob/master/COPYING

The MIT License

Copyright (c) 2012, 2014, 2015, 2016 Tatsuhiro Tsujikawa
Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ライセンス

Apache License 2.0

Copyright 2026-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.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_39_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.39+ x86-64

webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_39_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.39+ ARM64

webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_34_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.34+ x86-64

webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_34_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.34+ ARM64

webtransport_py-2026.1.0.dev1-cp314-cp314t-macosx_15_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.14tmacOS 15.0+ ARM64

webtransport_py-2026.1.0.dev1-cp314-cp314-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.14Windows x86-64

webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_39_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.39+ x86-64

webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_39_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.39+ ARM64

webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_34_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_34_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

webtransport_py-2026.1.0.dev1-cp314-cp314-macosx_15_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

File details

Details for the file webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 2a06f528a61d18c2b0469e2eee18f05e9c7a4cd131a13e9c5f80c14fc2629a36
MD5 95a94a67c77983f4bbd9769363e6b178
BLAKE2b-256 b75bcfde7b8a8dcb79151093f28e6ded400ccc321c52a1ed67efc4ca28b0ef90

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_39_x86_64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 2def874bd036068dc2bbc474355ac4d02e3945d43ddb491d30575d5095d28e1f
MD5 51eb0de4d5ed56ac84e40bd580e0862f
BLAKE2b-256 cb191d91415d5c3780085066e40fecfef3bcdd0850b78a144bdf912aa5f1c4cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_39_aarch64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 269f1dbc99bb7582244119de8e59abddb71b5a10b5f9a1608118fa4915a01869
MD5 10a4d1a6d860d00995b5cc224de6584f
BLAKE2b-256 5eda78ab3c2b9316bd8ac29b0030dc99b23eb68e2f1e882005bba2831da362bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_34_x86_64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 039fbfe965749496c773cdec0297386ec9f2bb004dc0dbba026a80a748e66693
MD5 3284d3507525840a5e3a4629365f364e
BLAKE2b-256 f949704f6dd16c139c4f199dc531712d3401895158661039f178eeeb2a70ca83

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314t-manylinux_2_34_aarch64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314t-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314t-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ae7334eb85c4fd69bce34600445d99793326268f7021f19ee6598d5f6b18bd47
MD5 1ee9ac356bd78e5efb45f90034b426d8
BLAKE2b-256 8f8aa47331fc990d1ca047e27ba85957a9f3643d637483e44783480ff41ebae7

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314t-macosx_15_0_arm64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 795d4f2493985173eb78d4eca9a692ce38a6a7891ea94e0db2c0e685da1c8b42
MD5 0bd0d6f85e70b315c5dfa107e3d92794
BLAKE2b-256 a7ead259c320cf1c0824ee81a0aa2ec331d1c5c4a13b5d1766963c7c5f9c87e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314-win_amd64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 c9595941997388027340d8751709eb9a61d52068fe820aa185a3e74dfc0caa4b
MD5 9db47a79639198a969f5b50673fe309f
BLAKE2b-256 11edd273abd36194ccef30626f147d5ab9874a375f5aa820aeef5bbc8e3c4fc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_39_x86_64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 5a97feb6441a5acdcb1955a9a8b715b6f5f20f0b936f389fd752e95543d370ff
MD5 24453421b86fee98785ef6bb84beb6dd
BLAKE2b-256 7a9fb7940f2f0e4a13f9f015ed73f7d9e8e3f0c42b5689f02361bfd67ecf78ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_39_aarch64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9fb23edafd8f79ecfc50041dcbe1271d7ed2e2f5ae4355234c0b72f99c8b425e
MD5 1f9b290579ee8f337cd9a51506d809c8
BLAKE2b-256 6bd15ea60de0973da61d5ec58dec3cdf93793ca4ac264a27574f7e60c90f1dde

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_34_x86_64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 295844771e5aca42f309891ad93ddd5ae1c0e26f72f8c85b9be5f79dd43afdf1
MD5 97bfd0a49d28ec6063b8a8e2ff2195e6
BLAKE2b-256 f03cc2599ff73bdc913d34224b8f6b8f4d3a95e03588022fc4d9fb8adfd1d800

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314-manylinux_2_34_aarch64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 webtransport_py-2026.1.0.dev1-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for webtransport_py-2026.1.0.dev1-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2ec579f1e715bf79403d0cb20c1d8dd1d67b899f8336d1f9bf6c9383358d7da5
MD5 892ea73483df3305eb13b1a2b7752631
BLAKE2b-256 bd7fe259f1b6ce0fe3ddbaa76d9a06ff81337bbe3e0d08cfa713a3f24e9a7cdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtransport_py-2026.1.0.dev1-cp314-cp314-macosx_15_0_arm64.whl:

Publisher: wheel.yml on shiguredo/webtransport-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 Sentry Error logging StatusPage Status page