Skip to main content

EchoRPC

Bidirectional JSON-RPC 2.0 over WebSocket for Python.

Install

pip install echorpc

Quick Start

Server

from echorpc import EchoServer

server = EchoServer(port=9100, auth_handler=lambda p: p["token"] == "secret")

# Define a command that clients can call
@server.command("add")
def add(params):
    return {"sum": params["a"] + params["b"]}

# Listen for events from clients
@server.event("chat")
async def on_chat(data):
    print("on_chat", data)

await server.start()

Client

from echorpc import EchoClient

client = EchoClient("ws://localhost:9100", token="secret")

# Let the server call you back
client.register("double", lambda p: p["x"] * 2)

# Subscribe to events
client.subscribe("chat", lambda data: print(data))

await client.connect()

# Call a server command
result = await client.request("add", {"a": 1, "b": 2})

# Publish event to the server
await client.publish("chat", {"text": "hello"})

# Send multiple calls at once
results = await client.batch_request([
    ("add", {"a": 1, "b": 2}),
    ("add", {"a": 3, "b": 4}),
])

Error Codes

Code Name Meaning
-32700 Parse error Invalid JSON
-32601 Method not found No such method
-32603 Internal error Handler threw
-32001 Not connected No active connection
-32002 Timeout Request timed out
-32003 Auth failed Authentication rejected

License

MIT License © 2026-PRESENT Del Wang

Release files for echorpc 1.0.0

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

Source distribution (sdist)

Source distribution for echorpc 1.0.0
File Size Uploaded
echorpc-1.0.0.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for echorpc 1.0.0
File Interpreter ABI Platform
echorpc-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.2 kB

Release files / echorpc-1.0.0.tar.gz

Download URL echorpc-1.0.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bc82970be25848d2bdc75fc5606c369b643a4186365c56f04fb93d772bfb4e41
BLAKE2b-256 checksum
How to use checksums
296fab37fb406aa8902b1a41354b683b88b15fc811e7869168f0b40a604d5a92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.2

Release files / echorpc-1.0.0-py3-none-any.whl

Download URL echorpc-1.0.0-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a5d71b11fd22958c131e1ccd56d653c198b04fbd95f234688baec3a6f2b1de3
BLAKE2b-256 checksum
How to use checksums
af93ff090a44e6627b1cd6337845753202ec0065dc018d4a45953b85d6aff8fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

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