book_offers - XRPL

Example code for the book_offers JSON RPC method. Сomplete guide on how to use book_offers JSON RPC in GetBlock Web3 documentation.

This method retrieves a list of offers, also known as the order book, between two currencies.

Parameters

Parameter
Type
Required
Description

taker_gets

object

Yes

Currency taker receives

taker_pays

object

Yes

Currency taker pays

ledger_hash

string

No

Ledger hash

ledger_index

string/number

No

Ledger index

limit

number

No

Maximum results

taker

string

No

Perspective account

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": "book_offers",
    "params": [{
        "taker_gets": {"currency": "XRP"},
        "taker_pays": {
            "currency": "USD",
            "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
        },
        "limit": 10
    }],
    "id": "getblock.io"
}'

Response Example

Response Parameters

Parameter
Type
Description

offers

array

Order book entries

TakerGets

object/string

Receiving amount

TakerPays

object/string

Paying amount

ledger_current_index

integer

current ledger

Use Cases

  • View order book

  • Build trading UI

  • Calculate exchange rates

Error Handling

Error Code
Description

invalidParams

Invalid parameters

SDK Integration

Last updated

Was this helpful?