{"id":13468916,"url":"https://github.com/websocket-client/websocket-client","last_synced_at":"2025-12-11T21:48:43.043Z","repository":{"id":1263421,"uuid":"1202362","full_name":"websocket-client/websocket-client","owner":"websocket-client","description":"WebSocket client for Python","archived":false,"fork":false,"pushed_at":"2025-11-10T09:41:44.000Z","size":1431,"stargazers_count":3692,"open_issues_count":32,"forks_count":775,"subscribers_count":78,"default_branch":"master","last_synced_at":"2025-12-07T12:21:40.541Z","etag":null,"topics":["python","rfc-6455","websocket","websocket-client","websockets","websockets-client"],"latest_commit_sha":null,"homepage":"https://websocket-client.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/websocket-client.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2010-12-28T06:35:25.000Z","updated_at":"2025-11-28T04:12:59.000Z","dependencies_parsed_at":"2023-12-15T05:31:22.893Z","dependency_job_id":"cbe46b9a-c2a5-43f1-b90c-5c2d29f7921e","html_url":"https://github.com/websocket-client/websocket-client","commit_stats":{"total_commits":1021,"total_committers":228,"mean_commits":4.478070175438597,"dds":0.6376101860920667,"last_synced_commit":"52329c4956f88133f45ecd510668776cd8a96ebf"},"previous_names":["liris/websocket-client"],"tags_count":86,"template":false,"template_full_name":null,"purl":"pkg:github/websocket-client/websocket-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websocket-client%2Fwebsocket-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websocket-client%2Fwebsocket-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websocket-client%2Fwebsocket-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websocket-client%2Fwebsocket-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/websocket-client","download_url":"https://codeload.github.com/websocket-client/websocket-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websocket-client%2Fwebsocket-client/sbom","scorecard":{"id":592293,"data":{"date":"2025-07-07","repo":{"name":"github.com/websocket-client/websocket-client","commit":"52329c4956f88133f45ecd510668776cd8a96ebf"},"scorecard":{"version":"v5.2.1-18-gbb9c347d","commit":"bb9c347dff6349d986baab6578a46d68a5524c62"},"score":4.2,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":2,"reason":"Found 8/30 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Warn: no topLevel permission defined: .github/workflows/codecoverage.yml:1","Warn: no topLevel permission defined: .github/workflows/doctest.yml:1","Warn: no topLevel permission defined: .github/workflows/lint-black.yml:1","Warn: no topLevel permission defined: .github/workflows/lint-flake8.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codecoverage.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/codecoverage.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codecoverage.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/codecoverage.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/codecoverage.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/codecoverage.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/doctest.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/doctest.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/doctest.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/doctest.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-black.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/lint-black.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/lint-black.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/lint-black.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-flake8.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/lint-flake8.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-flake8.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/websocket-client/websocket-client/lint-flake8.yml/master?enable=pin","Warn: pipCommand not pinned by hash: upload.sh:9","Warn: pipCommand not pinned by hash: .github/workflows/build.yml:27","Warn: pipCommand not pinned by hash: .github/workflows/build.yml:31","Warn: pipCommand not pinned by hash: .github/workflows/codecoverage.yml:17","Warn: pipCommand not pinned by hash: .github/workflows/codecoverage.yml:21","Warn: pipCommand not pinned by hash: .github/workflows/codecoverage.yml:23","Warn: pipCommand not pinned by hash: .github/workflows/codecoverage.yml:28","Warn: pipCommand not pinned by hash: .github/workflows/doctest.yml:19","Warn: pipCommand not pinned by hash: .github/workflows/lint-flake8.yml:19","Info:   0 out of   9 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   9 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: OSSFuzz integration found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T22:16:03.198Z","repository_id":1263421,"created_at":"2025-08-20T22:16:03.198Z","updated_at":"2025-08-20T22:16:03.198Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27634654,"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","status":"online","status_checked_at":"2025-12-10T02:00:12.818Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","rfc-6455","websocket","websocket-client","websockets","websockets-client"],"created_at":"2024-07-31T15:01:21.817Z","updated_at":"2025-12-11T21:48:43.023Z","avatar_url":"https://github.com/websocket-client.png","language":"Python","readme":"[![docs](https://readthedocs.org/projects/websocket-client/badge/?style=flat)](https://websocket-client.readthedocs.io/)\n[![Build Status](https://github.com/websocket-client/websocket-client/actions/workflows/build.yml/badge.svg)](https://github.com/websocket-client/websocket-client/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/websocket-client/websocket-client/branch/master/graph/badge.svg?token=pcXhUQwiL3)](https://codecov.io/gh/websocket-client/websocket-client)\n[![PyPI Downloads](https://pepy.tech/badge/websocket-client)](https://pepy.tech/project/websocket-client)\n[![PyPI version](https://img.shields.io/pypi/v/websocket_client)](https://pypi.org/project/websocket_client/)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# websocket-client\n\nwebsocket-client is a WebSocket client for Python. It provides access\nto low level APIs for WebSockets. websocket-client implements version\n[hybi-13](https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-13)\nof the WebSocket protocol. This client does not currently support the\npermessage-deflate extension from\n[RFC 7692](https://tools.ietf.org/html/rfc7692).\n\n## Documentation\n\nThis project's documentation can be found at\n[https://websocket-client.readthedocs.io/](https://websocket-client.readthedocs.io/)\n\n## Contributing\n\nPlease see the [contribution guidelines](https://github.com/websocket-client/websocket-client/blob/master/CONTRIBUTING.md)\n\n## Installation\n\nYou can use `pip install websocket-client` to install, or `pip install -e .`\nto install from a local copy of the code. This module is tested on Python 3.9+.\n\nThere are several optional dependencies that can be installed to enable\nspecific websocket-client features.\n- To install `python-socks` for proxy usage and `wsaccel` for a minor performance boost, use:\n `pip install websocket-client[optional]`\n- To install `websockets` to run unit tests using the local echo server, use:\n `pip install websocket-client[test]`\n- To install `Sphinx` and `sphinx_rtd_theme` to build project documentation, use:\n `pip install websocket-client[docs]`\n\nWhile not a strict dependency, [rel](https://github.com/bubbleboy14/registeredeventlistener)\nis useful when using `run_forever` with automatic reconnect. Install rel with `pip install rel`.\n\nFootnote: Some shells, such as zsh, require you to escape the `[` and `]` characters with a `\\`.\n\n## Usage Tips\n\nCheck out the documentation's FAQ for additional guidelines:\n[https://websocket-client.readthedocs.io/en/latest/faq.html](https://websocket-client.readthedocs.io/en/latest/faq.html)\n\nKnown issues with this library include lack of WebSocket Compression\nsupport (RFC 7692) and [minimal threading documentation/support](https://websocket-client.readthedocs.io/en/latest/threading.html).\n\n## Performance\n\nThe `send` and `validate_utf8` methods can sometimes be bottleneck.\nYou can disable UTF8 validation in this library (and receive a\nperformance enhancement) with the `skip_utf8_validation` parameter.\nIf you want to get better performance, install wsaccel. While\nwebsocket-client does not depend on wsaccel, it will be used if\navailable. wsaccel doubles the speed of UTF8 validation and\noffers a very minor 10% performance boost when masking the\npayload data as part of the `send` process. Numpy used to\nbe a suggested performance enhancement alternative, but\n[issue #687](https://github.com/websocket-client/websocket-client/issues/687)\nfound it didn't help.\n\n## Examples\n\nMany more examples are found in the\n[examples documentation](https://websocket-client.readthedocs.io/en/latest/examples.html).\n\n### Long-lived Connection\n\nMost real-world WebSockets situations involve longer-lived connections.\nThe WebSocketApp `run_forever` loop will automatically try to reconnect\nto an open WebSocket connection when a network\nconnection is lost if it is provided with:\n\n- a `dispatcher` argument (async dispatcher like rel or pyevent)\n- a non-zero `reconnect` argument (delay between disconnection and attempted reconnection)\n\n`run_forever` provides a variety of event-based connection controls\nusing callbacks like `on_message` and `on_error`.\n`run_forever` **does not automatically reconnect** if the server\ncloses the WebSocket gracefully (returning\n[a standard websocket close code](https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1)).\n[This is the logic](https://github.com/websocket-client/websocket-client/pull/838#issuecomment-1228454826) behind the decision.\nCustomizing behavior when the server closes\nthe WebSocket should be handled in the `on_close` callback.\nThis example uses [rel](https://github.com/bubbleboy14/registeredeventlistener)\nfor the dispatcher to provide automatic reconnection.\n\n```python\nimport websocket\nimport _thread\nimport time\nimport rel\n\ndef on_message(ws, message):\n    print(message)\n\ndef on_error(ws, error):\n    print(error)\n\ndef on_close(ws, close_status_code, close_msg):\n    print(\"### closed ###\")\n\ndef on_open(ws):\n    print(\"Opened connection\")\n\nif __name__ == \"__main__\":\n    websocket.enableTrace(True)\n    ws = websocket.WebSocketApp(\"wss://api.gemini.com/v1/marketdata/BTCUSD\",\n                              on_open=on_open,\n                              on_message=on_message,\n                              on_error=on_error,\n                              on_close=on_close)\n\n    ws.run_forever(dispatcher=rel, reconnect=5)  # Set dispatcher to automatic reconnection, 5 second reconnect delay if connection closed unexpectedly\n    rel.signal(2, rel.abort)  # Keyboard Interrupt\n    rel.dispatch()\n```\n\n### Short-lived Connection\n\nThis is if you want to communicate a short message and disconnect\nimmediately when done. For example, if you want to confirm that a WebSocket\nserver is running and responds properly to a specific request.\n\n```python\nfrom websocket import create_connection\n\nws = create_connection(\"ws://echo.websocket.events/\")\nprint(ws.recv())\nprint(\"Sending 'Hello, World'...\")\nws.send(\"Hello, World\")\nprint(\"Sent\")\nprint(\"Receiving...\")\nresult =  ws.recv()\nprint(\"Received '%s'\" % result)\nws.close()\n```\n","funding_links":[],"categories":["Python","HTML","Websocket Utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebsocket-client%2Fwebsocket-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebsocket-client%2Fwebsocket-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebsocket-client%2Fwebsocket-client/lists"}