XRP — book, deposit, get, nft, ripple, channel, Methods, server (1/2)
API reference for XRP. All methods ->
Part 1 of 2: 1 · 2
book_offers
Retrieves info on the currency exchange offers.
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.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON-RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):taker_gets(object; required): The asset the account taking the offer would receive, as a currency without an amount.taker_pays(object; required): The asset the account taking the offer would pay, as a currency without an amount.domain(hash; optional): The ledger entry ID of a permissioned domain. If provided, return offers from the corresponding permissioned DEX instead of using the open DEX. (Requires the PermissionedDEX amendment. Open for Voting: 48.57%)ledger_hash(hash; optional): The unique hash of the ledger version to use. (See Specifying Ledgers)ledger_index(ledger index; optional): The ledger index of the ledger to use, or a shortcut string to choose a ledger automatically. (See Specifying Ledgers)limit(number; optional): The maximum number of offers to return. The response may include fewer results.taker(string; optional): 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.)
Returns
The response follows the standard format, with a successful result containing the following fields:
ledger_current_index(ledger index; optional): Omitted ifledger_indexis provided. The ledger index of the current in-progress ledger version, which was used to retrieve this information.ledger_index(ledger index; optional): Omitted ifledger_current_indexis provided. The ledger index of the ledger version that was used when retrieving this data, as requested.ledger_hash(hash; optional): The identifying hash of the ledger version that was used when retrieving this data, as requested.offers(array): Array of offer objects, as described below.
Each member of the offers array contains canonical fields of an Offer entry and can also contain the following additional fields:
owner_funds(string): Amount of theTakerGetscurrency 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; optional): (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; optional): (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 ratiotaker_paysdivided bytaker_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.)
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "book_offers",
"params": [
{
"taker": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"taker_gets": {
"currency": "XRP"
},
"taker_pays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
},
"limit": 10
}
]
}'
Response example
{
"result": {
"ledger_current_index": 100604206,
"offers": [
{
"Account": "rdmZRvr9aBdGwzF2DwYBnHxTUDomJoiaQ",
"BookDirectory": "DFA3B6DDAB58C7E8E5D944E736DA4B7046C30E4F460FD9DE4F07346FDFE9BD33",
"BookNode": "0",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "8",
"PreviousTxnID": "4F34894FC227EBC36B0469672C533DB245DB8CB9FAC59E49A7B058D3A0ED08F6",
"PreviousTxnLgrSeq": 100604145,
"Sequence": 99505926,
"TakerGets": "9117876",
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "18.49086962"
},
"index": "8FA868A2EFF6B0CF195126639615DBE9251AE5E5559E428450D7F260E2D16CBA",
"owner_funds": "16902114",
"quality": "0.000002027979939626291"
}
],
"status": "success",
"validated": false
}
}
deposit_authorized
Checks whether an account is authorized to send money directly to another account.
The deposit_authorized command indicates whether one account is authorized to send payments directly to another. See Deposit Authorization for information on how to require authorization to deliver money to your account.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON-RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):source_account(string — address; required): The sender of a possible payment.destination_account(string — address; required): The recipient of a possible payment.ledger_hash(hash; optional): A 32-byte hex string for the ledger version to use. (See Specifying Ledgers)ledger_index(ledger index; optional): The ledger index of the ledger to use, or a shortcut string to choose a ledger automatically. (See Specifying Ledgers)credentials(array; optional): A set of credentials to take into account when checking if the sender can send funds to the destination. Each member of the array must be the unique ID of a Credential entry in the ledger. Cannot be an empty array.
Note: If you provide a set of credentials that does not exactly match a set of credentials preauthorized by the destination, the payment is not authorized, even if the destination has preauthorized a subset of those credentials. This matches the behavior of transaction processing.
Returns
credentials(array of hash; optional): The credentials specified in the request, if any.deposit_authorized(boolean; required): Whether the specified source account is authorized to send payments directly to the destination account. Iftrue, either the destination account does not require deposit authorization or the source account is preauthorized.destination_account(string — address; required): The destination account specified in the request.ledger_hash(string; optional): The identifying hash of the ledger that was used to generate this response.ledger_index(number — ledger index; optional): The ledger index of the ledger version that was used to generate this response.ledger_current_index(number — ledger index; optional): The ledger index of the current in-progress ledger version, which was used to generate this response.source_account(string — address; required): The source account specified in the request.validated(boolean; optional): Iftrue, the information comes from a validated ledger version.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "deposit_authorized",
"params": [
{
"source_account": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de",
"destination_account": "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8",
"credentials": [
"A182EFBD154C9E80195082F86C1C8952FC0760A654B886F61BB0A59803B4387B",
"383D269D6C7417D0A8716B09F5DB329FB17B45A5EFDBAFB82FF04BC420DCF7D5"
],
"ledger_index": "validated"
}
]
}'
Response example
{
"result": {
"credentials": [
"A182EFBD154C9E80195082F86C1C8952FC0760A654B886F61BB0A59803B4387B",
"383D269D6C7417D0A8716B09F5DB329FB17B45A5EFDBAFB82FF04BC420DCF7D5"
],
"deposit_authorized": true,
"destination_account": "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8",
"ledger_hash": "BD03A10653ED9D77DCA859B7A735BF0580088A8F287FA2C5403E0A19C58EF322",
"ledger_index": 8,
"source_account": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de",
"status": "success",
"validated": true
}
}
get_aggregate_price
Calculates the aggregate price of specified Oracle instances.
The get_aggregate_price method retrieves the aggregate price of specified Oracle objects, returning three price statistics: mean, median, and trimmed mean.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON-RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):base_asset(string; required): The currency code of the asset to be priced.quote_asset(string; required): The currency code of the asset to quote the price of the base asset.trim(number; optional): The percentage of outliers to trim. Valid trim range is 1–25. If included, the API returns statistics for thetrimmed mean.trim_threshold(number; optional): Defines a time range in seconds for filtering out older price data. Default value is 0, which doesn't filter any data.oracles(array; required): An array of oracle identifier objects. You must list between 1 and 200 oracle identifiers.
Each member of the oracles array is an oracle identifier object with the following fields:
account(string; required): The XRPL account that controls theOracleobject.oracle_document_id(number; required): A unique identifier of the price oracle for theAccount.
Returns
entire_set(object): The statistics from the collected oracle prices.entire_set.mean(string — number): The simple mean.entire_set.size(number): The size of the data set to calculate the mean.entire_set.standard_deviation(string — number): The standard deviation.
trimmed_set(object; optional): The trimmed statistics from the collected oracle prices. Only appears if thetrimfield was specified in the request.trimmed_set.mean(string — number): The simple mean of the trimmed data.trimmed_set.size(number): The size of the data to calculate the trimmed mean.trimmed_set.standard_deviation(string — number): The standard deviation of the trimmed data.
time(number): The most recent timestamp out of allLastUpdateTimevalues, represented in Unix time.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "get_aggregate_price",
"params": [
{
"ledger_index": "current",
"base_asset": "XRP",
"quote_asset": "USD",
"trim": 20,
"oracles": [
{
"account": "rNZ9m6AP9K7z3EVg6GhPMx36V4QmZKeWds",
"oracle_document_id": 34
},
{
"account": "rMVKq8zrVsJZQFEiTARyC6WfZznhhLMcNi",
"oracle_document_id": 100
},
{
"account": "r92kJTnUbUUq15t2BBZYGYxY79RnNc7rLQ",
"oracle_document_id": 2
}
]
}
]
}'
Response example
{
"result": {
"entire_set": {
"mean": "0.78",
"size": 3,
"standard_deviation": "0.03464101615137754"
},
"ledger_current_index": 3677185,
"median": "0.8",
"time": 1724877762,
"trimmed_set": {
"mean": "0.78",
"size": 3,
"standard_deviation": "0.03464101615137754"
},
"validated": false
},
"status": "success",
"type": "response"
}
nft_buy_offers
Retrieves a list of all buy offers for the NFT specified.
The nft_buy_offers method returns a list of buy offers for a given NFToken object.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON-RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):nft_id(string; required): The unique identifier of a NFToken object.ledger_hash(string; optional): The unique hash of the ledger version to use. (See Specifying Ledgers)ledger_index(string or number; optional): The ledger index of the ledger to use, or a shortcut string to choose a ledger automatically. (See Specifying Ledgers)limit(integer; optional): Limit the number of NFT buy offers to retrieve. This value cannot be lower than 50 or more than 500. Positive values outside this range are replaced with the closest valid option. The default is 250.marker(marker; optional): Value from a previous paginated response. Resume retrieving data where that response left off.
Returns
The response follows the standard format, with a successful result containing the following fields:
nft_id(string): The NFToken these offers are for, as specified in the request.offers(array): A list of buy offers for the token. Each of these is formatted as a Buy Offer (see below).limit(number; optional): Thelimit, as specified in the request.marker(marker; optional): Server-defined value indicating the response is paginated. Pass this to the next call to resume where this call left off. Omitted when there are no pages of information after this one.
Buy Offers
Each member of the offers array represents one NFTokenOffer object to buy the NFT in question and has the following fields:
amount(string or object): The amount offered to buy the NFT for, as a String representing an amount in drops of XRP, or an object representing an amount of a fungible token. (See Specifying Currency Amounts)flags(number): A set of bit-flags for this offer. See NFTokenOffer flags for possible values.nft_offer_index(string): The ledger object ID of this offer.owner(string): The account that placed this offer.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "nft_buy_offers",
"params": [
{
"nft_id": "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007",
"ledger_index": "validated"
}
]
}'
Response example
{
"result": {
"nft_id": "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007",
"offers": [
{
"amount": "1500",
"flags": 0,
"nft_offer_index": "3212D26DB00031889D4EF7D9129BB0FA673B5B40B1759564486C0F0946BA203F",
"owner": "rsuHaTvJh1bDmDoxX9QcKP7HEBSBt4XsHx"
}
],
"status": "success"
}
}
nft_sell_offers
Retrieves a list of all sell offers for the NFT specified.
The nft_sell_offers method returns a list of sell offers for a given NFToken object.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON-RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):nft_id(string; required): The unique identifier of a NFToken object.ledger_hash(string; optional): The unique hash of the ledger version to use. (See Specifying Ledgers)ledger_index(string or number; optional): The ledger index of the ledger to use, or a shortcut string to choose a ledger automatically. (See Specifying Ledgers)limit(integer; optional): Limit the number of NFT sell offers to retrieve. This value cannot be lower than 50 or more than 500. Positive values outside this range are replaced with the closest valid option. The default is 250.marker(marker; optional): Value from a previous paginated response. Resume retrieving data where that response left off.
Returns
nft_id(string): The NFToken these offers are for, as specified in the request.offers(array): A list of buy offers for the token. Each of these is formatted as a Sell Offer (see below).limit(number; optional): Thelimit, as specified in the request.marker(marker; optional): Server-defined value indicating the response is paginated. Pass this to the next call to resume where this call left off. Omitted when there are no pages of information after this one.
Sell Offers
Each member of the offers array represents one NFTokenOffer object to buy the NFT in question and has the following fields:
amount(string or object): The amount offered to sell the NFT for, as a String representing an amount in drops of XRP, or an object representing an amount of a fungible token. (See Specifying Currency Amounts)flags(number): A set of bit-flags for this offer. See NFTokenOffer flags for possible values.nft_offer_index(string): The ledger object ID of this offer.owner(string): The account that placed this offer.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "nft_sell_offers",
"params": [
{
"nft_id": "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007"
}
]
}'
Response example
{
"result": {
"nft_id": "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007",
"offers": [
{
"amount": "1000",
"flags": 1,
"nft_offer_index": "9E28E366573187F8E5B85CE301F229E061A619EE5A589EF740088F8843BF10A1",
"owner": "rLpSRZ1E8JHyNDZeHYsQs1R5cwDCB3uuZt"
}
],
"status": "success"
}
}