larzrpc
JSON-RPC 2.0 over HTTP — client and server, in pure Python. Zero dependencies.
Expose Python functions as a network API and call them from anywhere, using the
standard JSON-RPC 2.0 protocol — no framework, no code generation, no
dependencies. The server is one decorator and one serve() call; the client
calls remote methods as if they were local attributes.
# server.py
from larzrpc import RPCServer
app = RPCServer()
@app.method
def add(a, b):
return a + b
app.serve("127.0.0.1", 8080)
# client.py
from larzrpc import RPCClient
api = RPCClient("http://127.0.0.1:8080")
api.add(2, 3) # 5 (attribute access -> remote call)
api.call("add", a=10, b=1) # 11 (keyword params)
api.notify("log", "hi") # fire-and-forget notification
Why
- Zero dependencies. The client is
urllib, the server ishttp.server— both standard library. Nothing to install. - Standard protocol. Real JSON-RPC 2.0: positional and named params, batch requests, notifications, and the canonical error codes — so it interoperates with any compliant peer, not just itself.
- Ergonomic. Register a method with a decorator; call it as
client.method(...). Server errors surface as a realRPCErroron the client with the code and data intact. - Testable & embeddable. The dispatch core is a pure
request -> responsefunction (no sockets), and both client and server take a pluggable transport, so you can wire them together in-process — no network needed. - Mount anywhere. Use the built-in threaded server, or the included WSGI app under gunicorn/waitress/larz.
Install
pip install larzrpc
Server
from larzrpc import RPCServer, RPCError
app = RPCServer()
@app.method # exposed as "transfer"
def transfer(src, dst, amount):
if amount <= 0:
raise RPCError("amount must be positive", code=1001, data={"amount": amount})
...
return {"ok": True}
@app.method(name="account.balance")
def balance(account_id):
...
app.methods() # ["account.balance", "transfer"]
app.serve("0.0.0.0", 8080) # threaded HTTP server
Or embed it:
app.dispatch(request_dict) # -> response dict (pure, no transport)
app.handle_json(raw_json_string) # -> response JSON (handles batch + parse errors)
app.wsgi # a WSGI application
Client
from larzrpc import RPCClient, RPCError
api = RPCClient("http://127.0.0.1:8080")
try:
api.transfer("a", "b", 100)
except RPCError as e:
e.code, e.message, e.data # structured error from the server
Tests
python -m unittest discover -s tests -v # 20 tests incl. a live localhost round-trip
The Larz stack
Pure-Python, zero-dependency building blocks:
- larz — money-native web framework
- larzchain — from-scratch PoW blockchain
- larzmoney — exact, penny-perfect money
- larzcrypt — pure-Python cryptography toolkit
- larzdb — crash-safe embedded database
- larzagent — zero-dep AI agent framework
- larzchart — data to inline SVG charts
- larzmark — Markdown + SEO static sites
- larztask — durable background job queue
- larzvault — encrypted secrets manager
- larzvm — deterministic gas-metered VM
- larzcache — LRU/TTL/tiered caching
- larzvalidate — schema validation
- larzid — decentralized identity
- larzrpc — this library
License
MIT © larz-scripter
Metadata
Release files for larzrpc 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| larzrpc-0.1.0.tar.gz | 9.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzrpc-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / larzrpc-0.1.0.tar.gz
| Download URL | larzrpc-0.1.0.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb51134264777524f1ca17a3524c5f2aa6d14599d175e69671eb8b5770980536
|
|
BLAKE2b-256 checksum How to use checksums |
5631ccc0584256724e51d6426fc81002037cfa15f8edb295d72eb9cbc00f188f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzrpc-0.1.0-py3-none-any.whl
| Download URL | larzrpc-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a526b4cc6127a5436efe14d0756cd56cf5efd3120db6b33c1a5fea1c2c1f975
|
|
BLAKE2b-256 checksum How to use checksums |
d83a480ea805e5b31c06b1c9074052a8bc293a10e2e14ed6ae58fbf99394a172
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for larzrpc 0.1.0
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.