{"library":"pysignalr","title":"PySignalR Client","description":"pysignalr is a modern, reliable, and async-ready client for the SignalR protocol, designed to connect Python applications to SignalR hubs. It is currently at version 1.3.1 and maintains an active release cadence with regular updates and new feature additions, ensuring compatibility with the latest Python versions and SignalR protocol specifications.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pysignalr"],"cli":null},"imports":["from pysignalr.client import SignalRClient","from pysignalr.messages import CompletionMessage"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import asyncio\nfrom contextlib import suppress\nfrom typing import Any, Dict, List\nfrom pysignalr.client import SignalRClient\nfrom pysignalr.messages import CompletionMessage\nimport os\n\nasync def on_open() -> None:\n    print('Connected to the server')\n\nasync def on_close() -> None:\n    print('Disconnected from the server')\n\nasync def on_message(message: List[Dict[str, Any]]) -> None:\n    print(f'Received message: {message}')\n\nasync def on_client_result(message: list[dict[str, Any]]) -> str:\n    print(f'Received message requesting result: {message}')\n    return 'reply_from_client'\n\nasync def on_error(message: CompletionMessage) -> None:\n    print(f'Received error: {message.error}')\n\nasync def main() -> None:\n    # Replace with your SignalR hub URL\n    # For example, a public API like TzKT.io or your own local/remote hub\n    signalr_url = os.environ.get('SIGNALR_HUB_URL', 'https://api.tzkt.io/v1/ws')\n    access_token = os.environ.get('SIGNALR_ACCESS_TOKEN', '') # Optional: for authenticated hubs\n\n    client_args = {'url': signalr_url}\n    if access_token:\n        # For authenticated hubs, provide an access token factory\n        client_args['access_token_factory'] = lambda: access_token\n\n    client = SignalRClient(**client_args)\n    client.on_open(on_open)\n    client.on_close(on_close)\n    client.on_error(on_error)\n\n    # Register handlers for specific events from the server\n    client.on('operations', on_message) # Example: subscribing to 'operations' event\n    client.on('client_result', on_client_result) # Example: handling a server request for a client result\n\n    await asyncio.gather(\n        client.run(),\n        # Example: Sending a message to the server (e.g., to subscribe to a topic)\n        client.send('SubscribeToOperations', [{}]), \n    )\n\nif __name__ == '__main__':\n    with suppress(KeyboardInterrupt, asyncio.CancelledError):\n        asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to establish a connection to a SignalR hub, register event handlers for incoming messages, and send messages to the server. It includes examples for connection lifecycle events (open, close, error) and handling specific server events, including those requesting a client result.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"1.2.0","pypi_latest":"1.3.2","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":4.7,"avg_import_s":0.7,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.53,"mem_mb":16.6,"disk_size":"30.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.7,"import_time_s":0.39,"mem_mb":16.6,"disk_size":"33M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.71,"mem_mb":18,"disk_size":"33.0M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.3,"import_time_s":0.63,"mem_mb":18,"disk_size":"36M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.89,"mem_mb":18.4,"disk_size":"24.8M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.3,"import_time_s":0.81,"mem_mb":18.3,"disk_size":"27M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.84,"mem_mb":18.6,"disk_size":"24.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.7,"import_time_s":0.82,"mem_mb":18.6,"disk_size":"27M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"30.1M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pysignalr","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":6.6,"import_time_s":null,"mem_mb":null,"disk_size":"33M"}]}}