RPC Commands
The Cadenza WebSocket API uses RPC (Remote Procedure Call) for request/response operations over the Centrifugo protocol.
Communication Style
RPC provides synchronous request/response communication over WebSocket:
┌──────────┐ ┌──────────────┐ ┌──────────┐
│ Client │ │ Centrifugo │ │ Cadenza │
└────┬─────┘ └──────┬───────┘ └────┬─────┘
│ │ │
│ RPC Request (method, params) │ │
│────────────────────────────────▶│ │
│ │ Forward to handler │
│ │────────────────────────────────▶│
│ │ │
│ │ Response (result/error) │
│ │◀────────────────────────────────│
│ RPC Response │ │
│◀────────────────────────────────│ │
Method Naming Convention
RPC methods follow the pattern: {category}.{resource}.{action}
| Category | Purpose | Description |
|---|---|---|
command.* | Write operations | Create, update, delete, mutate state |
query.* | Read operations | List, get, fetch data |
Examples:
command.trade_order.submit- Submit a new order (write)query.instrument.list- List instruments (read)command.trading_account.connect- Connect account (write)query.orderbook.get- Get order book (read)
Making RPC Calls
# Pattern for RPC calls
result = await client.rpc(method, params)
# Using SDK models
params = RpcListInstrumentsParams(venue=Venue.BINANCE, limit=50)
result = await client.rpc("query.instrument.list", params.to_dict())
parsed = RpcListInstrumentsResult.from_dict(result.data)
Response Format
All RPC responses follow a consistent structure:
Success Response:
| Field | Type | Description |
|---|---|---|
data | object/array | Response payload |
Error Response:
| Field | Type | Description |
|---|---|---|
error | object | Error details |
error.code | integer | Error code |
error.message | string | Error description |
Error Handling
When an RPC call fails, the response contains an error object with a code and message. Error codes follow the format 22XXX where 22 indicates a business logic error.
Common error codes:
| Code | Message | Description |
|---|---|---|
| 22015 | Invalid argument | Invalid argument for operation |
| 22016 | Not found | Requested resource not found |
| 22017 | Already exist | Resource already exists |
| 22018 | Permission denied | Insufficient permissions |
| 22023 | Unauthorized | Not authorized for this operation |
For the complete list of error codes and handling patterns, see Error Handling.
RPC Commands Reference
System
| Method | Description | Details |
|---|---|---|
query.system.info | Get API information | View |
query.system.check | Health check | View |
Venues
| Method | Description | Details |
|---|---|---|
query.venue.list | List supported venues | View |
Instruments
| Method | Description | Details |
|---|---|---|
query.instrument.list | List instruments | View |
command.instrument.sync | Sync from exchange | View |
command.instrument.enable | Enable instrument | View |
command.instrument.disable | Disable instrument | View |
Order Books
| Method | Description | Details |
|---|---|---|
query.orderbook.get | Get order book | View |
query.orderbook.list | List order books | View |
Trading Accounts
| Method | Description | Details |
|---|---|---|
query.trading_account.list | List accounts | View |
command.trading_account.connect | Connect account | View |
command.trading_account.disconnect | Disconnect account | View |
command.trading_account.enable | Enable account | View |
command.trading_account.disable | Disable account | View |
Credentials
| Method | Description | Details |
|---|---|---|
query.credential.list | List credentials | View |
command.credential.create | Create credential | View |
command.credential.verify | Verify credential | View |
command.credential.revoke | Revoke credential | View |
Trade Orders
| Method | Description | Details |
|---|---|---|
query.trade_order.list | List orders | View |
query.trade_order.get | Get order | View |
command.trade_order.submit | Submit order | View |
command.trade_order.cancel | Cancel order | View |
Portfolios
| Method | Description | Details |
|---|---|---|
query.portfolio.list | List portfolios | View |
query.portfolio.get | Get portfolio | View |
Subscriptions
| Method | Description | Details |
|---|---|---|
query.subscription.list | List subscriptions | View |
command.subscription.create | Create subscription | View |