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:

#!/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 corountine-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.

Metadata

Release files for websockets 4.0

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

Built distributions (wheels)

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

Total release size: 949.6 kB

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

Download URL websockets-4.0-cp36-cp36m-win_amd64.whl
Size 78.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
093623790afe43998fc997509ed05dc28fe0604d49f32a5a4de682767d62af30
BLAKE2b-256 checksum
How to use checksums
2d30adb6de8b21541214606c4506902dee6313217ce8b61ba572a0555418d5c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0-cp36-cp36m-win32.whl
Size 77.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
98216a9c7b5f95a8b0b9680db3696cc34798c76d70153e35a3efc7d1ce7992a9
BLAKE2b-256 checksum
How to use checksums
5f000cbe5814e9a2d5cbd420f8f131ff7306e6ba9ee95a9a3540f27bff69841a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0-cp36-cp36m-manylinux1_x86_64.whl
Size 81.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
557ec0d3a67667fbc8367694fe9c68cb8f4a0ed5a28d3a2bb38079e06d582c0b
BLAKE2b-256 checksum
How to use checksums
8ec0299825af6f915f6996a9e4351fda10bf9292f57ceb08ae005e66a91d982a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0-cp36-cp36m-manylinux1_i686.whl
Size 80.9 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
720ed7de9eb4de2287872aba00ead7e11438855436be3c4eba7d9e5021a52e1d
BLAKE2b-256 checksum
How to use checksums
6897d6f11dded820f1c2aa9e97dfa4718e5f8d3d2b7821bbd9366f4e290100a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0-cp35-cp35m-win_amd64.whl
Size 78.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
ba4e5692ac160e4568425dfedfc5917861bd822864ae473b77bbd46942a28245
BLAKE2b-256 checksum
How to use checksums
279bc577e4714db79e09ead7c0c5846e7e82065dd2539f5d8c8d15cf293a5f1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

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

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

Download URL websockets-4.0-cp34-cp34m-win_amd64.whl
Size 75.8 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
177ffe213a02980b4351ef1c3c3fe207d92b794921d6b472f27fee5843d9e391
BLAKE2b-256 checksum
How to use checksums
14248ecd8bf8f8f43f6b3df808d5880a3ab533815a949ce962ff992921abcf5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0-cp34-cp34m-win32.whl
Size 76.1 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
efc06608064fe6060dc2744acdc6046e5ca2902caf487cdd8b80141739a8626c
BLAKE2b-256 checksum
How to use checksums
66a6d528c8fa7f4ce2b445de0268dafc5a0aecd1697d30737202ad008c8b6b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL websockets-4.0-cp34-cp34m-manylinux1_i686.whl
Size 80.7 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
bf5aa50e48d777f231fcbe3c43e86dd8a1198ee0d47d8c472359bfb07893f0d9
BLAKE2b-256 checksum
How to use checksums
19b87a518223c0c0d1f1afebe41fd14efb56610a5faa1042bf9daa117548c1be
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

5.0

16 release files

This release

4.0 This release

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