Skip to main content

rtd pypi-v pypi-pyversions pypi-l pypi-wheel circleci codecov

What is websockets?

websockets is a library for building WebSocket servers and clients in Python with a focus on correctness and simplicity.

Built on top of asyncio, Python’s standard asynchronous I/O framework, it provides an elegant coroutine-based API.

Here’s a client that says “Hello world!”:

#!/usr/bin/env python

import asyncio
import websockets

async def hello(uri):
    async with websockets.connect(uri) as websocket:
        await websocket.send("Hello world!")

asyncio.get_event_loop().run_until_complete(
    hello('ws://localhost:8765'))

And here’s an echo server (for Python ≥ 3.6):

#!/usr/bin/env python

import asyncio
import websockets

async def echo(websocket, path):
    async for message in websocket:
        await websocket.send(message)

asyncio.get_event_loop().run_until_complete(
    websockets.serve(echo, 'localhost', 8765))
asyncio.get_event_loop().run_forever()

Does that look good? Start here.

Why should I use websockets?

The development of websockets is shaped by four principles:

  1. Simplicity: all you need to understand is msg = await ws.recv() and await ws.send(msg); websockets takes care of managing connections so you can focus on your application.

  2. Robustness: websockets is built for production; for example it was the only library to handle backpressure correctly before the issue became widely known in the Python community.

  3. Quality: websockets is heavily tested. Continuous integration fails under 100% branch coverage. Also it passes the industry-standard Autobahn Testsuite.

  4. Performance: memory use is configurable. An extension written in C accelerates expensive operations. It’s pre-compiled for Linux, macOS and Windows and packaged in the wheel format for each system and Python version.

Documentation is a first class concern in the project. Head over to Read the Docs and see for yourself.

Professional support is available if you — or your company — are so inclined. Get in touch.

(If you contribute to websockets and would like to become an official support provider, let me know.)

Why shouldn’t I use websockets?

  • If you prefer callbacks over coroutines: websockets was created to provide the best coroutine-based API to manage WebSocket connections in Python. Pick another library for a callback-based API.

  • If you’re looking for a mixed HTTP / WebSocket library: websockets aims at being an excellent implementation of RFC 6455: The WebSocket Protocol and RFC 7692: Compression Extensions for WebSocket. Its support for HTTP is minimal — just enough for a HTTP health check.

  • If you want to use Python 2: websockets builds upon asyncio which only works on Python 3. websockets requires Python ≥ 3.4.

What else?

Bug reports, patches and suggestions welcome! Just open an issue or send a pull request.

websockets is released under the BSD license.

Release files for websockets 5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for websockets 5.0
File Size Uploaded
websockets-5.0.tar.gz 68.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for websockets 5.0
File
websockets-5.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
websockets-5.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
websockets-5.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
websockets-5.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
websockets-5.0-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
websockets-5.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
websockets-5.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
websockets-5.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
websockets-5.0-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
websockets-5.0-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
websockets-5.0-cp34-cp34m-win_amd64.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-64 Details
websockets-5.0-cp34-cp34m-win32.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-32 Details
websockets-5.0-cp34-cp34m-manylinux1_x86_64.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64 Details
websockets-5.0-cp34-cp34m-manylinux1_i686.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32 Details
websockets-5.0-cp34-cp34m-macosx_10_6_intel.whl CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386) Details

Total release size: 1.3 MB

Release files / websockets-5.0.tar.gz

Download URL websockets-5.0.tar.gz
Size 68.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4ea90a598b546233a4c61bef98db4171ac30f1302826729af30001ac1f471098
BLAKE2b-256 checksum
How to use checksums
0dea0cc41f9ab63b4af08840a667b047d6fab6406aebb076932ef877a4511f78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp36-cp36m-win_amd64.whl

Download URL websockets-5.0-cp36-cp36m-win_amd64.whl
Size 81.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
e8d9823a0eb52b5a2cc39b44c13bf99644f006778459da1d0175bc5e92fd8112
BLAKE2b-256 checksum
How to use checksums
d89018e9415f2035bd182b2269b30f4fc087ff8757c00912cbc3864e516339b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp36-cp36m-win32.whl

Download URL websockets-5.0-cp36-cp36m-win32.whl
Size 81.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
8ae1b897c61f8e4306c9a18c5c4ecb695738bd4824f330cc7aa45caa95d971d8
BLAKE2b-256 checksum
How to use checksums
54ce0e28c39bcb719932838284bc8bfaf7cfb86262d12bd088a67266992eab34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL websockets-5.0-cp36-cp36m-manylinux1_x86_64.whl
Size 85.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
ed77c1a7779ff4060920470dc303c9dcba88f22ef769e46868e9bb9ea537ce26
BLAKE2b-256 checksum
How to use checksums
72affbd01573d6faf8f897f6645c45e788551b55652e26fe5fd1eaff503f6377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp36-cp36m-manylinux1_i686.whl

Download URL websockets-5.0-cp36-cp36m-manylinux1_i686.whl
Size 84.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
1d8ce82e5a0c7947b204d0b1abe0f66bc247dc5c605aa5a339df7d91012356e5
BLAKE2b-256 checksum
How to use checksums
cc6e9f550c8194d15946da9b20560389c7e2c3305ea211205eb0f5872847850a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp36-cp36m-macosx_10_6_intel.whl

Download URL websockets-5.0-cp36-cp36m-macosx_10_6_intel.whl
Size 79.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
58f891a21d430b837d61686f50d52efebd415164f9626d10b2000e50ab097439
BLAKE2b-256 checksum
How to use checksums
4901c4ef4b70fa78ce13521c14a9d5a782be14bcd75010a8f87131343552f069
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp35-cp35m-win_amd64.whl

Download URL websockets-5.0-cp35-cp35m-win_amd64.whl
Size 80.1 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
d069ce1bc3af02ad35ee6aef6f82c4b0ce64ea5e3f9585935830cce5c74340bf
BLAKE2b-256 checksum
How to use checksums
0de66c75fe4ab3708d950929deb09108e5d501c38a9eb5138b8b357a5e039f25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp35-cp35m-win32.whl

Download URL websockets-5.0-cp35-cp35m-win32.whl
Size 79.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e0f4f59900820cc97d17cc0e7d6e0fc9c0d4a65e906d4e2c09217f89a34f1d71
BLAKE2b-256 checksum
How to use checksums
cfdf44bdb9360d0e721c3f16ca192a5384c47cc13e91ac10257194466d02de31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp35-cp35m-manylinux1_x86_64.whl

Download URL websockets-5.0-cp35-cp35m-manylinux1_x86_64.whl
Size 83.6 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
2de152acdcffd37e05042ff285f8ef25046c005927d3ea78606ed99524135545
BLAKE2b-256 checksum
How to use checksums
6eaf8eb36f03a25eb80161fe8c78a4b3ab8b9d22c2b9789968ab05f1e83eddc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp35-cp35m-manylinux1_i686.whl

Download URL websockets-5.0-cp35-cp35m-manylinux1_i686.whl
Size 83.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
fe8c6e72c2eaf4d03b9e0d33d7f9f14b9a84f47252b1d4670b798ade572ea360
BLAKE2b-256 checksum
How to use checksums
a13c8d17a1f1adbb1f4389dba6f463d9c1d511e31ac0a8c2875f3608cc77a9a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp35-cp35m-macosx_10_6_intel.whl

Download URL websockets-5.0-cp35-cp35m-macosx_10_6_intel.whl
Size 77.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
a21861e60d336d21c6f99958b14b26e977a81eaf8abd5a478e8ee9d091a6cac1
BLAKE2b-256 checksum
How to use checksums
2df100ea01d64a79a2b73669c27f909ee6c549a30969241fa01595164486a8ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp34-cp34m-win_amd64.whl

Download URL websockets-5.0-cp34-cp34m-win_amd64.whl
Size 76.7 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
da93fe3b9ebbd0425539c818eaf73ac55301a3449eaa9349029b39098216dac3
BLAKE2b-256 checksum
How to use checksums
a4fa0f10f6b5da7bfbf7c0508f6003979dcedb696f6690f145c181653b1cd773
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp34-cp34m-win32.whl

Download URL websockets-5.0-cp34-cp34m-win32.whl
Size 77.0 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
9242d6df28fe4c3768c4c6f5b6b6acdfaf1cbc272140c40c0b1c755dc5a5a7bc
BLAKE2b-256 checksum
How to use checksums
5f2340e60a9fb98119386875f649ae3d55d9e4b29b0dcb1dc391deceba42b222
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp34-cp34m-manylinux1_x86_64.whl

Download URL websockets-5.0-cp34-cp34m-manylinux1_x86_64.whl
Size 82.2 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
b05205ecdf809fd3c20d597912e9a184d382fcff31c81d86499e5c78aa412346
BLAKE2b-256 checksum
How to use checksums
a77509f6d1a98780421491aabae562887ab196d4dcc2f7066dfe6b2c0c5bcae0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp34-cp34m-manylinux1_i686.whl

Download URL websockets-5.0-cp34-cp34m-manylinux1_i686.whl
Size 81.6 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
ac76ccd2a5e36c4e980d00042d217635f0f92ef1574d8ca13e81a22add3f801d
BLAKE2b-256 checksum
How to use checksums
8056a55b4a597d12736dae51271759fd09f299e7b4ac57a03fbeff08eaca3ef1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / websockets-5.0-cp34-cp34m-macosx_10_6_intel.whl

Download URL websockets-5.0-cp34-cp34m-macosx_10_6_intel.whl
Size 76.2 kB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
d71d1e24deceb18ccea605adef388d9a452b719e09320698e64b522df9029532
BLAKE2b-256 checksum
How to use checksums
7077027f36c57357f9b1ce128905e8a77892c84b73f687836ee27f56a4b0cb74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

17.1

148 release files

17.0

108 release files

16.1

109 release files

16.0

61 release files

15.0

69 release files

14.2

69 release files

14.1

69 release files

14.0

69 release files

13.1

86 release files

13.0

86 release files

12.0

72 release files

11.0

70 release files

10.4

69 release files

10.3

48 release files

10.2

48 release files

10.1

48 release files

10.0

25 release files

9.1

33 release files

9.0.2

33 release files

9.0

22 release files

8.1

22 release files

8.0.2

11 release files

8.0.1

11 release files

8.0

11 release files

7.0

21 release files

6.0

21 release files

5.0.1

13 release files

This release

5.0 This release

16 release files

4.0

12 release files

3.4

20 release files

3.3

2 release files

3.2

2 release files

3.1

1 release file

3.0

2 release files

2.7

2 release files

2.6

2 release files

2.5

2 release files

2.4

2 release files

2.3

2 release files

2.2

1 release file

2.1

1 release file

2.0

2 release files

1.0

2 release files

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page