On this page

latest contributor to this doc

Last Edit:

@smk762

Enable Balance Streaming

API-v2stream::balance::enable

Using this method, you can enable balance events streaming for a specific coin, to a specific client. For ETH-like coins and tokens, you can also specify the streaming interval in seconds (to avoid excessive polling leading to upstream API rate limts)

ParameterTypeRequiredDefaultDescription
coinstring-Ticker of the coin to activate streaming for. The coin must be activated first.
client_idinteger0In the case of a single client, this defaults to 0. This ID can be used to access data via http://localhost:7783/event-stream?id=1
configobject-EVM only. A standard StreamingConfig object.

The client defines its own id when opening a connection to the stream, and each client_id can only be viewed by a single client (i.e. the ?id= url param won't work in more than one browser tab). The selected coin must be enabled prior to enabling streaming.

ParameterTypeDescription
streamer_idstringAn identifier for the data stream. This can be used later to disable streaming for the event with stream::disable.

Balance Enable

POST
balance_enable
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "stream::balance::enable",
  "mmrpc": "2.0",
  "params": {
    "coin": "MATIC",
    "config": {
      "stream_interval_seconds": 15
    },
    "client_id": 1
  }
}

Here is an example of the stream data you should be able to see in http://localhost:7783/event-stream?id=1 once a balance change is detected:

data: {"_type":"BALANCE:MATIC","message":[{"ticker":"MATIC","address":"0xc11b6070c84a1e6fc62b2a2acf70831545d5edd4","balance":{"spendable":"2.00000001","unspendable":"0"}}]}

ParameterTypeDescription
CoinNotFoundstringThe specified coin was not found or is not activated yet
UnknownClientstringNo client has an open connection using this client_id
ClientAlreadyListeningstringThe requested events are already being sent to the client_id
EnableErrorstringThe config object is not used in non-EVM coins or other configuration errors