asyncio-friendly Python wrapper for libdatachannel (WebRTC Data Channels)
Project description
aiolibdatachannel
An asyncio-friendly Python wrapper around
libdatachannel — a
lightweight C/C++ WebRTC stack. aiolibdatachannel exposes WebRTC
Peer Connections and Data Channels through idiomatic async/await
Python.
Scope: PeerConnection + DataChannel only. WebSocket and Media/RTP transport are deliberately disabled in this build to keep the wheel small and the API focused.
Install
pip install aiolibdatachannel
Wheels are published for Linux (manylinux_2_28 x86_64 / aarch64) and
macOS (arm64, 14.0+). Intel Macs and Windows aren't currently covered —
Intel Mac because Apple Silicon is the modern target, Windows because
libdatachannel dynamically links OpenSSL and the wheel packaging for
that on Windows is still open.
The Python↔C boundary uses nanobind's
stable-ABI mode (Py_LIMITED_API): libdatachannel and its static
dependencies (usrsctp, libjuice, OpenSSL) link directly into the
extension, and a single cp312-abi3-<platform> wheel per architecture
covers every CPython 3.12+ interpreter — no per-Python-version build.
The binding layer itself is deliberately thin: native trampolines route
every libdatachannel callback through a single Python dispatcher, and
the asyncio semantics live in the pure-Python wrapper on top, not in C++.
Quickstart
import asyncio
from aiolibdatachannel import PeerConnection, RTCConfiguration
async def main() -> None:
config = RTCConfiguration(ice_servers=["stun:stun.l.google.com:19302"])
async with PeerConnection(config) as pc:
dc = await pc.create_data_channel("chat")
offer = await pc.create_offer()
# ... ship `offer` to the peer via your signalling channel ...
answer_sdp = await receive_answer_from_peer()
await pc.set_remote_description(answer_sdp, "answer")
await dc.wait_open()
await dc.send(b"hello")
async for message in dc:
print("got", message)
asyncio.run(main())
See examples/offerer.py and examples/answerer.py for a runnable pair of
scripts that negotiate over stdin/stdout.
Logging
Route libdatachannel's internal logs through Python's standard
logging module:
import logging
from aiolibdatachannel import install_python_logger
logging.basicConfig(level=logging.INFO)
install_python_logger() # logger name defaults to "aiolibdatachannel"
Severities are translated (FATAL→CRITICAL, ERROR→ERROR,
WARNING→WARNING, INFO→INFO, DEBUG/VERBOSE→DEBUG) and the filter
threshold on the native side is derived from the Python logger's
effective level, so you don't pay to format lines that would be filtered
out anyway. Pass install_python_logger(my_logger) or
install_python_logger(level=LogLevel.DEBUG) to customise.
Development
Full native build (requires a C++17 toolchain, CMake ≥ 3.24, ninja, and OpenSSL headers):
git clone --recursive https://github.com/social-home-io/aiolibdatachannel.git
cd aiolibdatachannel
pip install -e .[dev]
pytest
If you only need to touch the Python wrapper (async semantics, async
iterators, event plumbing), skip the C++ build and run against the
pure-Python stand-in from tests/_fake_native.py:
pip install pytest pytest-asyncio
PYTHONPATH=. pytest -m "not native"
tests/conftest.py injects the fake into sys.modules whenever
AIOLIB_REQUIRE_NATIVE is unset. Tests marked @pytest.mark.native
(loopback, cancellation, logging, errors, stress) are auto-skipped in
that mode.
Long-running soak tests (10 000-message loopback, 100 PC lifecycles,
shutdown-leak subprocess checks) live behind a stress marker and
are off by default — enable with pytest -m stress or
AIOLIB_STRESS=1 pytest. They also run nightly in CI.
See docs/BUILDING.md for detailed build instructions, including how to switch TLS backends and how to bump the bundled libdatachannel version.
License
This project is licensed under the Mozilla Public License 2.0, matching the license of libdatachannel which it bundles and statically links. See LICENSE and vendor/libdatachannel/LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiolibdatachannel-2026.5.7.tar.gz.
File metadata
- Download URL: aiolibdatachannel-2026.5.7.tar.gz
- Upload date:
- Size: 11.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
031d032dc86e55380a74e7f249cc90b5baa43bb781920265bebb0e982f83309a
|
|
| MD5 |
90bacaada45ed24b81599d3687e076df
|
|
| BLAKE2b-256 |
a4e506c23347de8c8eb8708f14e13febd75ed884d3f6aa8c23de16a98ab96531
|
Provenance
The following attestation bundles were made for aiolibdatachannel-2026.5.7.tar.gz:
Publisher:
release.yml on social-home-io/aiolibdatachannel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiolibdatachannel-2026.5.7.tar.gz -
Subject digest:
031d032dc86e55380a74e7f249cc90b5baa43bb781920265bebb0e982f83309a - Sigstore transparency entry: 1460844288
- Sigstore integration time:
-
Permalink:
social-home-io/aiolibdatachannel@cfd2af39abdccec4e9f1f36d4d97804affabccac -
Branch / Tag:
refs/tags/2026.5.7 - Owner: https://github.com/social-home-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cfd2af39abdccec4e9f1f36d4d97804affabccac -
Trigger Event:
push
-
Statement type:
File details
Details for the file aiolibdatachannel-2026.5.7-cp312-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: aiolibdatachannel-2026.5.7-cp312-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 4.0 MB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec7d01fed49dd5bd73acfba82f36a7af768cf6acf64574ba258b495a58708c09
|
|
| MD5 |
dd5d71a65b117e46c91d8f833fd9ec67
|
|
| BLAKE2b-256 |
e7544828fa6c48ebc2d30aaddfa42b095ea0400523bb5b2c0cbc2c2aa425b627
|
Provenance
The following attestation bundles were made for aiolibdatachannel-2026.5.7-cp312-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on social-home-io/aiolibdatachannel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiolibdatachannel-2026.5.7-cp312-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
ec7d01fed49dd5bd73acfba82f36a7af768cf6acf64574ba258b495a58708c09 - Sigstore transparency entry: 1460844383
- Sigstore integration time:
-
Permalink:
social-home-io/aiolibdatachannel@cfd2af39abdccec4e9f1f36d4d97804affabccac -
Branch / Tag:
refs/tags/2026.5.7 - Owner: https://github.com/social-home-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cfd2af39abdccec4e9f1f36d4d97804affabccac -
Trigger Event:
push
-
Statement type:
File details
Details for the file aiolibdatachannel-2026.5.7-cp312-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: aiolibdatachannel-2026.5.7-cp312-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99c9e43e931ad74843609807628a8e6ec0ca4cf722d63cc0d47402711dc3b81a
|
|
| MD5 |
10a1eb557338435189d6e70f7266d54b
|
|
| BLAKE2b-256 |
b87fa1832df1d6854533b457d28ead1b062501a230ed91a9c50a12465edccfde
|
Provenance
The following attestation bundles were made for aiolibdatachannel-2026.5.7-cp312-abi3-manylinux_2_28_aarch64.whl:
Publisher:
release.yml on social-home-io/aiolibdatachannel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiolibdatachannel-2026.5.7-cp312-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
99c9e43e931ad74843609807628a8e6ec0ca4cf722d63cc0d47402711dc3b81a - Sigstore transparency entry: 1460844596
- Sigstore integration time:
-
Permalink:
social-home-io/aiolibdatachannel@cfd2af39abdccec4e9f1f36d4d97804affabccac -
Branch / Tag:
refs/tags/2026.5.7 - Owner: https://github.com/social-home-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cfd2af39abdccec4e9f1f36d4d97804affabccac -
Trigger Event:
push
-
Statement type:
File details
Details for the file aiolibdatachannel-2026.5.7-cp312-abi3-macosx_14_0_arm64.whl.
File metadata
- Download URL: aiolibdatachannel-2026.5.7-cp312-abi3-macosx_14_0_arm64.whl
- Upload date:
- Size: 4.5 MB
- Tags: CPython 3.12+, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b77cff8f545bb499e2efc80fd83503e8fbccb5f7b49427186f5132e2833e2a4
|
|
| MD5 |
33ab6b5f98c7c2b4002db8be0184abf4
|
|
| BLAKE2b-256 |
76c459d229288db1b323e15c5b111e6021265364fe7c599b0b597eb7a1a77e9b
|
Provenance
The following attestation bundles were made for aiolibdatachannel-2026.5.7-cp312-abi3-macosx_14_0_arm64.whl:
Publisher:
release.yml on social-home-io/aiolibdatachannel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiolibdatachannel-2026.5.7-cp312-abi3-macosx_14_0_arm64.whl -
Subject digest:
7b77cff8f545bb499e2efc80fd83503e8fbccb5f7b49427186f5132e2833e2a4 - Sigstore transparency entry: 1460844483
- Sigstore integration time:
-
Permalink:
social-home-io/aiolibdatachannel@cfd2af39abdccec4e9f1f36d4d97804affabccac -
Branch / Tag:
refs/tags/2026.5.7 - Owner: https://github.com/social-home-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cfd2af39abdccec4e9f1f36d4d97804affabccac -
Trigger Event:
push
-
Statement type: