subscribe - XPRL

Example code for the subscribe JSON RPC method. Complete guide to using subscribe JSON-RPC in the GetBlock Web3 documentation.

This method requests periodic notifications from the server when certain events happen.

Parameters

Parameter
Type
Required
Description

streams

array

No

Streams to subscribe

accounts

array

No

Accounts to watch

accounts_proposed

array

No

Accounts for proposed txs

books

array

No

Order books to watch

Request Example

curl --location --request POST 'https://xrp.getblock.io/mainnet/' \
--header 'x-api-key: YOUR-API-KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "subscribe",
    "params": [{
        "streams": ["ledger"]
    }],
    "id": "getblock.io"
}'

Response Example

Response Parameters

Parameter
Type
Description

ledger_index

number

Current ledger

status

string

Subscription status

Use Cases

  • Real-time ledger updates

  • Monitor account activity

  • Track order book changes

Error Handling

Error Code
Description

invalidParams

Invalid parameters

SDK Integration

Last updated

Was this helpful?