Library for building WebSocket servers and clients in Python
open sourceBSD-3-Clausefree
websockets is a Python library for building WebSocket servers and clients, focused on correctness, simplicity, robustness and performance. Its default implementation is a coroutine API on asyncio, with implementations on threading and trio too and a Sans-I/O layer for other projects to build on. It is tested for compliance with RFC 6455 (WebSocket) and RFC 7692 (compression), with 100% branch coverage, handles backpressure, and has a C extension that speeds up expensive operations, shipped as pre-built wheels. HTTP and WebSocket servers such as Uvicorn build on it for their WebSocket support.
Problems it solves
- run a WebSocket server in Python
- connect to a WebSocket server from a Python script
- add WebSockets to an asyncio app
Features
- WebSocket servers and clients for Python
- coroutine API on asyncio, plus threading and trio implementations
- Sans-I/O layer for integration in other projects
- compliance with RFC 6455 and RFC 7692 compression, with 100% branch coverage
- handles backpressure
- C extension, pre-built for Linux, macOS and Windows