Skip to main content

WebSockets

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.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 4.0.1
File Size Uploaded Provenance Actions
websockets-4.0.1.tar.gz 61.8 kB Without provenance Details for websockets-4.0.1.tar.gz

Built distributions (wheels)

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

Total release size: 1.2 MB

Release files / websockets-4.0.1.tar.gz

Download URL websockets-4.0.1.tar.gz
Size 61.8 kB
Tags Source
SHA-256 checksum
How to use checksums
da4d4fbe059b0453e726d6d993760065d69b823a27efc3040402a6fcfe6a1ed9
BLAKE2b-256 checksum
How to use checksums
b6126194aac840c65253e45a38912e318f9ac548f9ba86d75bdb8fe66841b335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0.1-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
1f3e5a52cab6daa3d432c7b0de0a14109be39d2bfaad033ee5de4a3d3e11dcdf
BLAKE2b-256 checksum
How to use checksums
16f60ca33b5cdb231926d27ea5f8796518bcaebeeba359094f33584c2e9c7781
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0.1-cp36-cp36m-win32.whl
Size 77.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
64896a6b3368c959b8096b655e46f03dfa65b96745249f374bd6a35705cc3489
BLAKE2b-256 checksum
How to use checksums
264d5efee3e39bf47dbe1d84c157b7d618b569d9068d79e385e52f8dde688ac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0.1-cp36-cp36m-manylinux1_x86_64.whl
Size 81.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
341824d8c9ad53fc43cca3fa9407f294125fa258592f7676640396501448e57e
BLAKE2b-256 checksum
How to use checksums
87bd532f1456c439accef8ddf54e3bf20081c416a4ce615ba7097218d669ff53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0.1-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
6df87698022aef2596bffdfecc96d656db59c8d719708c8a471daa815ee61656
BLAKE2b-256 checksum
How to use checksums
20ef311a66a4b295778aa9acd7eb784232fe58ae9b80d007b2d890bfe17f6f6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0.1-cp36-cp36m-macosx_10_6_intel.whl
Size 75.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
367ff945bc0950ad9634591e2afe50bf2222bc4fad1088a386c4bb700888026e
BLAKE2b-256 checksum
How to use checksums
4b9576a39368d0615c9eb8d26288833438bf8887a73cf9767cc2e6c6d27efeb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL websockets-4.0.1-cp35-cp35m-win_amd64.whl
Size 76.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
fecf51c13195c416c22422353b306dddb9c752e4b80b21e0fa1fccbe38246677
BLAKE2b-256 checksum
How to use checksums
48a3762809b60a9154e03cfa033a6142c4bb377e81597f2bff9fa173b583a975
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

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

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

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

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

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

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

Download URL websockets-4.0.1-cp34-cp34m-win32.whl
Size 73.6 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
fd81af8cf3e69f9a97f3a6c0623a0527de0f922c2df725f00cd7646d478af632
BLAKE2b-256 checksum
How to use checksums
03fff7c7462fc4684f36b4a4938547d6fe9279e48861eeaaba91de836762e760
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL websockets-4.0.1-cp34-cp34m-manylinux1_i686.whl
Size 78.3 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
0c31bc832d529dc7583d324eb6c836a4f362032a1902723c112cf57883488d8c
BLAKE2b-256 checksum
How to use checksums
845b3f23eb26208d177e7bca575bb9cfb3ce68285fc24efe5d5ac2609f325caa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

Security for websockets 4.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.0.1 This release

16 release files No provenance

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