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.1

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.1
File Size Uploaded
websockets-5.0.1.tar.gz 68.5 kB Details

Built distributions (wheels)

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

Total release size: 1.0 MB

Release files / websockets-5.0.1.tar.gz

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

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

Download URL websockets-5.0.1-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
d3724acff61ee1029fefc614cf005982338b033998a0b71fbb13a0a2fd99ab6f
BLAKE2b-256 checksum
How to use checksums
97c87d5405e29332a587cbc57b26dce045f25fcabf9ab617c880fe272146adf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-5.0.1-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
9049ec652713f5132b512d3498c2d37264580714ccc95dbc0f7f9622c3f6da7e
BLAKE2b-256 checksum
How to use checksums
766a4d88a29f6afe511bd9536cd418421d70b5dca3aca8571924e411fdba6c9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-5.0.1-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
43c332fc331541c57d40c124089b270d668c25a6b04908bd688969375db7327f
BLAKE2b-256 checksum
How to use checksums
4409c48fd04e293b999aaa1f78c32376d241aa042fce09475f9107ae2e811554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-5.0.1-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
39241fb291c1648e33dc41208be876a5771466291f0f6f7bff8f6732373084bd
BLAKE2b-256 checksum
How to use checksums
9546779d1f3578cd497d24a71bd011a80f17547fc61d227c4a34792e61da8482
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-5.0.1-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
0b7b561bcbf992edd54e961b89551b5b6073415a0446fe445bd6554d41dabb95
BLAKE2b-256 checksum
How to use checksums
1681e4d4db405b1ed0cc9a35fb5e74f63e45d33daa0e63e7223ff488507af717
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

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

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

Download URL websockets-5.0.1-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
29b676568e4fcb1a05064473b96243ef4e9391f251b4c485cf7f93507787b459
BLAKE2b-256 checksum
How to use checksums
924b5fc41ecbeb33f7fbf8f39a5457ae995a2125d695e04e6892f5de2cff738f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-5.0.1-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
a911beb8149d7dae9d4c942927c448c05c41dfaa9c002a6bc26e269df932769b
BLAKE2b-256 checksum
How to use checksums
8398ca5a7a24340a98a247ab4f05bc3578d4856ba577e85aba955453322db1ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-5.0.1-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
2469c98f2254878a49a6eda248d3ed8a89bbdca85cc316ff72ea15924cec9e1f
BLAKE2b-256 checksum
How to use checksums
f982f6702a719ae1e7921e588297b029e37d8e8f1dc3a6f67258a35a71640a7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-5.0.1-cp34-cp34m-manylinux1_i686.whl
Size 81.7 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
480259ec6e80f28859f23b5c231beb856fb96ab30e64ee621fdaf27da1515604
BLAKE2b-256 checksum
How to use checksums
ea53c0259e4a8f35be59adf4fc8b603727255071cbc127e9444adab49026bf39
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

This release

5.0.1 This release

13 release files

5.0

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