Python WebRTC

Bindings to the native WebRTC M152, with the API of the browsers: peer connections, data channels, media tracks and their frames, encoded transforms and stats, as the W3C specifications define them, in asyncio.

import asyncio
import webrtc


async def main():
    pc = webrtc.RTCPeerConnection()
    channel = pc.create_data_channel('chat')

    offer = await pc.create_offer()
    await pc.set_local_description(offer)
    print(pc.local_description.sdp)


asyncio.run(main())
pip install wrtc

Warning

Under development. Until the 1.0.0 release, compatibility between versions is not guaranteed.

Where to start

Quickstart

Install it and connect two peers with a data channel. Five minutes.

Quickstart
Guides

Connections, data channels, events and media, organised by what you are trying to do.

Guides
Examples

Every runnable example in the repository, inlined and ready to copy.

Examples
Media

Read the frames of a track, write your own, transform them on the way.

Media
API reference

Every interface, dictionary, enum and exception of the package.

API reference
Changelog

What changed in each release.

Change Log

What it covers

Names follow the specifications in snake_case (create_offer), and the camelCase originals (createOffer) work too. Enums compare equal to the strings of the specification, and dictionaries are typed dataclasses.

Supported platforms

Pre-built wheels for CPython 3.9 to 3.15, and free-threaded 3.14t and 3.15t, on:

Linux

macOS

Windows

x86_64 and aarch64 (glibc 2.27+, manylinux)

13+, Intel and Apple Silicon

x64

Elsewhere, pip builds it from sources. See Installation.