Skip to main content

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}

CategoryPurposeDescription
command.*Write operationsCreate, update, delete, mutate state
query.*Read operationsList, 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:

FieldTypeDescription
dataobject/arrayResponse payload

Error Response:

FieldTypeDescription
errorobjectError details
error.codeintegerError code
error.messagestringError 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:

CodeMessageDescription
22015Invalid argumentInvalid argument for operation
22016Not foundRequested resource not found
22017Already existResource already exists
22018Permission deniedInsufficient permissions
22023UnauthorizedNot authorized for this operation

For the complete list of error codes and handling patterns, see Error Handling.


RPC Commands Reference

System

MethodDescriptionDetails
query.system.infoGet API informationView
query.system.checkHealth checkView

Venues

MethodDescriptionDetails
query.venue.listList supported venuesView

Instruments

MethodDescriptionDetails
query.instrument.listList instrumentsView
command.instrument.syncSync from exchangeView
command.instrument.enableEnable instrumentView
command.instrument.disableDisable instrumentView

Order Books

MethodDescriptionDetails
query.orderbook.getGet order bookView
query.orderbook.listList order booksView

Trading Accounts

MethodDescriptionDetails
query.trading_account.listList accountsView
command.trading_account.connectConnect accountView
command.trading_account.disconnectDisconnect accountView
command.trading_account.enableEnable accountView
command.trading_account.disableDisable accountView

Credentials

MethodDescriptionDetails
query.credential.listList credentialsView
command.credential.createCreate credentialView
command.credential.verifyVerify credentialView
command.credential.revokeRevoke credentialView

Trade Orders

MethodDescriptionDetails
query.trade_order.listList ordersView
query.trade_order.getGet orderView
command.trade_order.submitSubmit orderView
command.trade_order.cancelCancel orderView

Portfolios

MethodDescriptionDetails
query.portfolio.listList portfoliosView
query.portfolio.getGet portfolioView

Subscriptions

MethodDescriptionDetails
query.subscription.listList subscriptionsView
command.subscription.createCreate subscriptionView