book_offers
Last updated
Last updated
The book_offers
method retrieves a list of Offers between two currencies, also known as an order book. The response omits unfunded Offers and reports how much of each remaining Offer's total is currently funded.
An example of the request format:
The request includes the following parameters:
Field
Type
Required?
Description
taker_gets
Object
Yes
The asset the account taking the Offer would receive, as a currency without an amount.
taker_pays
Object
Yes
The asset the account taking the Offer would pay, as a currency without an amount.
ledger_hash
[Hash][]
No
A 20-byte hex string for the ledger version to use. (See [Specifying Ledgers][])
ledger_index
[Ledger Index][]
No
The [ledger index][] of the ledger to use, or a shortcut string to choose a ledger automatically. (See [Specifying Ledgers][])
limit
Number
No
The maximum number of Offers to return. The response may include fewer results.
taker
String
No
The [Address][] of an account to use as a perspective. The response includes this account's Offers even if they are unfunded. (You can use this to see what Offers are above or below yours in the order book.)
An example of a successful response:
The response follows the [standard format][], with a successful result containing the following fields:
Field
Type
Description
ledger_current_index
[Ledger Index][]
(Omitted if ledger_current_index
is provided) The [ledger index][] of the current in-progress ledger version, which was used to retrieve this information.
ledger_index
[Ledger Index][]
(Omitted if ledger_current_index
provided) The ledger index of the ledger version that was used when retrieving this data, as requested.
ledger_hash
[Hash][]
(May be omitted) The identifying hash of the ledger version that was used when retrieving this data, as requested.
offers
Array
Array of offer objects, each of which has the fields of an Offer object
In addition to the standard Offer fields, the following fields may be included in members of the offers
array:
Field
Type
Description
owner_funds
String
Amount of the TakerGets
currency the side placing the offer has available to be traded. (XRP is represented as drops; any other currency is represented as a decimal value.) If a trader has multiple offers in the same book, only the highest-ranked offer includes this field.
taker_gets_funded
[Currency Amount][]
(Only included in partially-funded offers) The maximum amount of currency that the taker can get, given the funding status of the offer.
taker_pays_funded
[Currency Amount][]
(Only included in partially-funded offers) The maximum amount of currency that the taker would pay, given the funding status of the offer.
quality
String
The exchange rate, as the ratio taker_pays
divided by taker_gets
. For fairness, offers that have the same quality are automatically taken first-in, first-out. (In other words, if multiple people offer to exchange currency at the same rate, the oldest offer is taken first.)
Any of the [universal error types][].
invalidParams
- One or more fields are specified incorrectly, or one or more required fields are missing.
lgrNotFound
- The ledger specified by the ledger_hash
or ledger_index
does not exist, or it does exist but the server does not have it.
srcCurMalformed
- The taker_pays
field in the request is not formatted properly.
dstAmtMalformed
- The taker_gets
field in the request is not formatted properly.
srcIsrMalformed
- The issuer
field of the taker_pays
field in the request is not valid.
dstIsrMalformed
- The issuer
field of the taker_gets
field in the request is not valid.
badMarket
- The desired order book does not exist; for example, offers to exchange a currency for itself.