{"id":27704430,"url":"https://github.com/aaugustin/websockets","last_synced_at":"2025-04-26T01:01:55.115Z","repository":{"id":7746372,"uuid":"9113587","full_name":"python-websockets/websockets","owner":"python-websockets","description":"Library for building WebSocket servers and clients in Python","archived":false,"fork":false,"pushed_at":"2025-04-14T19:30:45.000Z","size":3339,"stargazers_count":5385,"open_issues_count":16,"forks_count":539,"subscribers_count":106,"default_branch":"main","last_synced_at":"2025-04-19T01:24:23.901Z","etag":null,"topics":["python","python3","websocket","websocket-client","websocket-library","websocket-server","websockets"],"latest_commit_sha":null,"homepage":"https://websockets.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/python-websockets.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"python-websockets","open_collective":"websockets","tidelift":"pypi/websockets"}},"created_at":"2013-03-30T08:59:30.000Z","updated_at":"2025-04-18T05:16:59.000Z","dependencies_parsed_at":"2023-11-11T22:06:39.882Z","dependency_job_id":"3d60e050-ffb3-4f42-b734-9094d1513436","html_url":"https://github.com/python-websockets/websockets","commit_stats":{"total_commits":1510,"total_committers":76,"mean_commits":19.86842105263158,"dds":"0.22980132450331126","last_synced_commit":"76f6f573e2ecb279230c2bf56c07bf4d4f717147"},"previous_names":["aaugustin/websockets"],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-websockets%2Fwebsockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-websockets%2Fwebsockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-websockets%2Fwebsockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-websockets%2Fwebsockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-websockets","download_url":"https://codeload.github.com/python-websockets/websockets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250917360,"owners_count":21507562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","python3","websocket","websocket-client","websocket-library","websocket-server","websockets"],"created_at":"2025-04-26T01:01:45.121Z","updated_at":"2025-04-26T01:01:55.093Z","avatar_url":"https://github.com/python-websockets.png","language":"Python","readme":".. image:: logo/horizontal.svg\n   :width: 480px\n   :alt: websockets\n\n|licence| |version| |pyversions| |tests| |docs| |openssf|\n\n.. |licence| image:: https://img.shields.io/pypi/l/websockets.svg\n    :target: https://pypi.python.org/pypi/websockets\n\n.. |version| image:: https://img.shields.io/pypi/v/websockets.svg\n    :target: https://pypi.python.org/pypi/websockets\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/websockets.svg\n    :target: https://pypi.python.org/pypi/websockets\n\n.. |tests| image:: https://img.shields.io/github/checks-status/python-websockets/websockets/main?label=tests\n   :target: https://github.com/python-websockets/websockets/actions/workflows/tests.yml\n\n.. |docs| image:: https://img.shields.io/readthedocs/websockets.svg\n   :target: https://websockets.readthedocs.io/\n\n.. |openssf| image:: https://bestpractices.coreinfrastructure.org/projects/6475/badge\n   :target: https://bestpractices.coreinfrastructure.org/projects/6475\n\nWhat is ``websockets``?\n-----------------------\n\nwebsockets is a library for building WebSocket_ servers and clients in Python\nwith a focus on correctness, simplicity, robustness, and performance.\n\n.. _WebSocket: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API\n\nBuilt on top of ``asyncio``, Python's standard asynchronous I/O framework, the\ndefault implementation provides an elegant coroutine-based API.\n\nAn implementation on top of ``threading`` and a Sans-I/O implementation are also\navailable.\n\n`Documentation is available on Read the Docs. \u003chttps://websockets.readthedocs.io/\u003e`_\n\n.. copy-pasted because GitHub doesn't support the include directive\n\nHere's an echo server with the ``asyncio`` API:\n\n.. code:: python\n\n    #!/usr/bin/env python\n\n    import asyncio\n    from websockets.asyncio.server import serve\n\n    async def echo(websocket):\n        async for message in websocket:\n            await websocket.send(message)\n\n    async def main():\n        async with serve(echo, \"localhost\", 8765) as server:\n            await server.serve_forever()\n\n    asyncio.run(main())\n\nHere's how a client sends and receives messages with the ``threading`` API:\n\n.. code:: python\n\n    #!/usr/bin/env python\n\n    from websockets.sync.client import connect\n\n    def hello():\n        with connect(\"ws://localhost:8765\") as websocket:\n            websocket.send(\"Hello world!\")\n            message = websocket.recv()\n            print(f\"Received: {message}\")\n\n    hello()\n\n\nDoes that look good?\n\n`Get started with the tutorial! \u003chttps://websockets.readthedocs.io/en/stable/intro/index.html\u003e`_\n\n.. raw:: html\n\n    \u003chr\u003e\n    \u003cimg align=\"left\" height=\"150\" width=\"150\" src=\"https://raw.githubusercontent.com/python-websockets/websockets/main/logo/tidelift.png\"\u003e\n    \u003ch3 align=\"center\"\u003e\u003ci\u003ewebsockets for enterprise\u003c/i\u003e\u003c/h3\u003e\n    \u003cp align=\"center\"\u003e\u003ci\u003eAvailable as part of the Tidelift Subscription\u003c/i\u003e\u003c/p\u003e\n    \u003cp align=\"center\"\u003e\u003ci\u003eThe maintainers of websockets and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. \u003ca href=\"https://tidelift.com/subscription/pkg/pypi-websockets?utm_source=pypi-websockets\u0026utm_medium=referral\u0026utm_campaign=readme\"\u003eLearn more.\u003c/a\u003e\u003c/i\u003e\u003c/p\u003e\n    \u003chr\u003e\n    \u003cp\u003e(If you contribute to \u003ccode\u003ewebsockets\u003c/code\u003e and would like to become an official support provider, \u003ca href=\"https://fractalideas.com/\"\u003elet me know\u003c/a\u003e.)\u003c/p\u003e\n\nWhy should I use ``websockets``?\n--------------------------------\n\nThe development of ``websockets`` is shaped by four principles:\n\n1. **Correctness**: ``websockets`` is heavily tested for compliance with\n   :rfc:`6455`. Continuous integration fails under 100% branch coverage.\n\n2. **Simplicity**: all you need to understand is ``msg = await ws.recv()`` and\n   ``await ws.send(msg)``. ``websockets`` takes care of managing connections\n   so you can focus on your application.\n\n3. **Robustness**: ``websockets`` is built for production. For example, it was\n   the only library to `handle backpressure correctly`_ before the issue\n   became widely known in the Python community.\n\n4. **Performance**: memory usage is optimized and configurable. A C extension\n   accelerates expensive operations. It's pre-compiled for Linux, macOS and\n   Windows and packaged in the wheel format for each system and Python version.\n\nDocumentation is a first class concern in the project. Head over to `Read the\nDocs`_ and see for yourself.\n\n.. _Read the Docs: https://websockets.readthedocs.io/\n.. _handle backpressure correctly: https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#websocket-servers\n\nWhy shouldn't I use ``websockets``?\n-----------------------------------\n\n* If you prefer callbacks over coroutines: ``websockets`` was created to\n  provide the best coroutine-based API to manage WebSocket connections in\n  Python. Pick another library for a callback-based API.\n\n* If you're looking for a mixed HTTP / WebSocket library: ``websockets`` aims\n  at being an excellent implementation of :rfc:`6455`: The WebSocket Protocol\n  and :rfc:`7692`: Compression Extensions for WebSocket. Its support for HTTP\n  is minimal — just enough for an HTTP health check.\n\n  If you want to do both in the same server, look at HTTP + WebSocket servers\n  that build on top of ``websockets`` to support WebSocket connections, like\n  uvicorn_ or Sanic_.\n\n.. _uvicorn: https://www.uvicorn.org/\n.. _Sanic: https://sanic.dev/en/\n\nWhat else?\n----------\n\nBug reports, patches and suggestions are welcome!\n\nTo report a security vulnerability, please use the `Tidelift security\ncontact`_. Tidelift will coordinate the fix and disclosure.\n\n.. _Tidelift security contact: https://tidelift.com/security\n\nFor anything else, please open an issue_ or send a `pull request`_.\n\n.. _issue: https://github.com/python-websockets/websockets/issues/new\n.. _pull request: https://github.com/python-websockets/websockets/compare/\n\nParticipants must uphold the `Contributor Covenant code of conduct`_.\n\n.. _Contributor Covenant code of conduct: https://github.com/python-websockets/websockets/blob/main/CODE_OF_CONDUCT.md\n\n``websockets`` is released under the `BSD license`_.\n\n.. _BSD license: https://github.com/python-websockets/websockets/blob/main/LICENSE\n","funding_links":["https://github.com/sponsors/python-websockets","https://opencollective.com/websockets","https://tidelift.com/funding/github/pypi/websockets","https://tidelift.com/subscription/pkg/pypi-websockets?utm_source=pypi-websockets\u0026utm_medium=referral\u0026utm_campaign=readme","https://tidelift.com/security"],"categories":["网络","资源列表","WebSocket","语言资源库","Web Frameworks \u0026 Tools","Python","WebSocket [🔝](#readme)","📚 فهرست","Web Frameworks \u0026 RESTful API","Tools per Language"],"sub_categories":["WebSocket","python","شبکه","Python"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaugustin%2Fwebsockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faaugustin%2Fwebsockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaugustin%2Fwebsockets/lists"}