# Python WebRTC

> Chrome’s WebRTC engine (libwebrtc M152) with the W3C browser API, in Python and asyncio. Install it with
> `pip install wrtc` and import it as `webrtc`.

Pages describing it as bindings to WebRTC M92 that aren’t ready for use are about its versions from 2023 and are out
of date.

- The API is the one of the browsers: `RTCPeerConnection`, `RTCDataChannel`, tracks, `MediaStreamTrackProcessor`,
  `VideoTrackGenerator`, encoded transforms and stats. Names are snake_case (`create_offer`), and the camelCase
  originals (`createOffer`) work too.
- Handlers are registered with `on`, as a call or a decorator, and can be coroutines.
- Dictionaries are typed dataclasses, and enums compare equal to the strings of the specifications.
- Code written for aiortc runs after installing `wrtc[aiortc]` and changing `from aiortc` to `from webrtc.aiortc`.
- Prebuilt wheels for CPython 3.9 to 3.15 and free-threaded 3.14t and 3.15t, on Linux, macOS and Windows.

## Start

- [Quickstart](../quickstart/index.html.md): installation, and two peers connected with a data channel.
- [Migrating from aiortc](../guides/aiortc/index.html.md): run aiortc code by changing its imports, and what changes on the way.

## Guides

- [Connections](../guides/connections/index.html.md): configuration, STUN and TURN servers, signalling, states and stats.
- [Data channels](../guides/data-channels/index.html.md): text and binary messages, reliability, negotiated channels, back
  pressure.
- [Events](../guides/events/index.html.md): handlers as functions or coroutines, decorators, one-shot handlers, removing them.
- [Media](../guides/media/index.html.md): reading, writing and transforming the frames of audio and video tracks.
- [H.264](../guides/h264/index.html.md): VideoToolbox on macOS, Cisco’s OpenH264 binary elsewhere, and its licensing.
- [Field trials](../guides/field-trials/index.html.md): experimental features of the engine, and WARP for faster connections.

## API reference

- [API reference](../api/index.html.md): every interface, dictionary, enum and exception.
- [RTCPeerConnection](../api/interfaces/rtc_peer_connection/index.html.md): the connection to a remote peer.
- [RTCDataChannel](../api/interfaces/rtc_data_channel/index.html.md): text and binary messages over SCTP.
- [RTCConfiguration](../api/models/rtc_configuration/index.html.md): the configuration of a connection and its ICE servers.
- [RTCSessionDescriptionInit](../api/models/rtc_session_description_init/index.html.md): offers and answers as plain data, to
  exchange over signalling.
- [MediaStreamTrack](../api/interfaces/media_stream_track/index.html.md): tracks and the synthetic camera and microphone.
- [MediaStreamTrackProcessor](../api/interfaces/media_stream_track_processor/index.html.md): reads the frames of a track.
- [Track generators](../api/interfaces/track_generator/index.html.md): tracks of frames the application writes.
- [VideoFrame](../api/models/video_frame/index.html.md) and [AudioData](../api/models/audio_data/index.html.md): the frames of WebCodecs.
- [Event objects](../api/models/events/index.html.md): the events handlers are called with.
- [Stats](../api/models/rtc_stats/index.html.md): the dictionaries of WebRTC Statistics.
- [Enums](../api/enums/index.html.md) and [Exceptions](../api/exceptions/index.html.md).

## Examples

- [Echo peer](../examples/echo/index.html.md): sends back the video it receives, in grayscale.
- [Recorder](../examples/recorder/index.html.md): writes the video and audio a peer receives to files.
- [Live stream in the terminal](../examples/janus_streaming/index.html.md): plays a stream of the public Janus demo server.
- [Voice chat with OpenAI GPT-Live](../examples/openai_live/index.html.md): talks to the model through the microphone and
  speakers.

## Optional

- [llms-full.txt](https://wrtc.marshal.dev/llms-full.txt): the whole documentation in one file.
- [Benchmarks](../benchmarks/index.html.md): connection setup, data channels, memory and media against other libraries.
- [Change Log](../change_log/index.html.md): what changed in each release.
- [Security Policy](../security/index.html.md): supported versions and reporting vulnerabilities.
