XRP — gateway, noripple, Methods, ledger
API reference for XRP. All methods ->
gateway_balances
Calculates total amounts issued by an account.
The gateway_balances method calculates the total balances issued by a given account, optionally excluding amounts held by operational addresses.
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):account(string): The Address to check. This should be the issuing address.strict(boolean; optional): Iftrue, only accept an address or public key for the account parameter. Defaults tofalse.hotwallet(string or array; optional): An operational address to exclude from the balances issued, or an array of such addresses.ledger_hash(string; optional): The unique hash of the ledger version to use. (See Specifying Ledgers.)ledger_index(string or unsigned integer; optional): The ledger index of the ledger version to use, or a shortcut string to choose a ledger automatically. (See Specifying Ledgers.)
Returns
The response follows the standard format, with a successful result containing the following fields:
account(string — address): The address of the account that issued the balances.obligations(object; omitted if empty): Total amounts issued to addresses not excluded, as a map of currencies to the total value issued.balances(object; omitted if empty): Amounts issued to thehotwalletaddresses from the request. The keys are addresses and the values are arrays of currency amounts they hold.assets(object; omitted if empty): Total amounts held that are issued by others. In the recommended configuration, the issuing address should have none.ledger_hash(string — hash; optional): The identifying hash of the ledger version 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): (Omitted ifledger_current_indexis provided). The ledger index of the current in-progress ledger version, which was used to retrieve this information.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "gateway_balances",
"params": [
{
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"hotwallet": [
"rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ",
"ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt"
],
"ledger_index": "validated",
"strict": true
}
]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"assets": {
"r9F6wk8HkXrgYWoJ7fsv4VrUBVoqDVtzkH": [
{
"currency": "BTC",
"value": "5444166510000000e-26"
}
],
"rPU6VbckqCLW4kb51CWqZdxvYyQrQVsnSj": [
{
"currency": "BTC",
"value": "1029900000000000e-26"
}
],
"rpR95n1iFkTqpoy1e878f4Z1pVHVtWKMNQ": [
{
"currency": "BTC",
"value": "4000000000000000e-30"
}
],
"rwmUaXsWtXU4Z843xSYwgt1is97bgY8yj6": [
{
"currency": "BTC",
"value": "8700000000000000e-30"
}
]
},
"balances": {
"rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ": [
{
"currency": "EUR",
"value": "144816.1965999999"
}
],
"ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt": [
{
"currency": "USD",
"value": "6677.38614"
}
]
},
"frozen_balances": {
"r4keXr5myiU4iTLh68ZqZ2CgsJ8dM9FSW6": [
{
"currency": "BTC",
"value": "0.091207822800868"
}
]
},
"ledger_hash": "9F04F45FC6A7B4BE8DA04580F7E4E23DCCE58A9FD73178296CA70319C5B799F1",
"ledger_index": 100185180,
"obligations": {
"BTC": "1761.964986208178",
"EUR": "813788.3511514511",
"GBP": "4973.797603049582",
"USD": "6734902.401181124"
},
"status": "success",
"validated": true
}
}
noripple_check
Gets recommended changes to an account's Default Ripple and No Ripple settings.
The noripple_check command provides a quick way to check the status of the Default Ripple field for an account and the No Ripple flag of its trust lines, compared with the recommended settings.
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):account(string): A unique identifier for the account, most commonly the account's address.role(string): Whether the address refers to agatewayoruser. Recommendations depend on the role of the account. Issuers must have Default Ripple enabled and must disable No Ripple on all trust lines. Users should have Default Ripple disabled, and should enable No Ripple on all trust lines.transactions(boolean; optional): Iftrue, include an array of suggested transactions, as JSON objects, that you can sign and submit to fix the problems. The default isfalse.limit(unsigned integer; optional): The maximum number of trust line problems to include in the results. Defaults to 300.ledger_hash(string; optional): The unique hash of the ledger version to use. (See Specifying Ledgers.)ledger_index(string or unsigned integer; optional): The ledger index of the ledger to use, or a shortcut string to choose a ledger automatically. (See Specifying Ledgers.)
Returns
The response follows the standard format, with a successful result containing the following fields:
ledger_current_index(number): The ledger index of the ledger used to calculate these results.problems(array): Array of strings with human-readable descriptions of the problems. This includes up to one entry if the account's Default Ripple setting is not as recommended, plus up tolimitentries for trust lines whose No Ripple setting is not as recommended.transactions(array; optional): If the request specifiedtransactionsastrue, this is an array of JSON objects, each of which is the JSON form of a transaction that should fix one of the described problems. The length of this array is the same as theproblemsarray, and each entry is intended to fix the problem described at the same index into that array.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "noripple_check",
"params": [
{
"account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"ledger_index": "current",
"limit": 2,
"role": "gateway",
"transactions": true
}
]
}'
Response example
{
"result": {
"ledger_current_index": 100203014,
"problems": [
"You should immediately set your default ripple flag",
"You should clear the no ripple flag on your USD line to rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"You should clear the no ripple flag on your EUR line to rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
"You should clear the no ripple flag on your CNY line to rnuF96W4SZoCJmbHYBFoJZpR8eCaxNvekK",
"You should clear the no ripple flag on your XAU line to r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z",
"You should clear the no ripple flag on your 015841551A748AD2C1F76FF6ECB0CCCD00000000 line to rs9M85karFkCRjvc6KMWn8Coigm9cbcgcx",
"You should clear the no ripple flag on your AUX line to r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z",
"You should clear the no ripple flag on your CNY line to razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA",
"You should clear the no ripple flag on your JPY line to rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"You should clear the no ripple flag on your USD line to rfF3PNkwkq1DygW2wum2HK3RGfgkJjdPVD",
"You should clear the no ripple flag on your USD line to r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X"
],
"status": "success",
"transactions": [
{
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"Fee": 10,
"Sequence": 1406,
"SetFlag": 8,
"TransactionType": "AccountSet"
},
{
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"Fee": 10,
"Flags": 262144,
"LimitAmount": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "5"
},
"Sequence": 1407,
"TransactionType": "TrustSet"
}
],
"validated": false
}
}
Ledger Methods:
A ledger version contains a header, a transaction tree, and a state tree, which contain account settings, trustlines, balances, transactions, and other data. Use these methods to retrieve ledger info.
ledger
Retrieves info on the ledger.
Retrieves information about the public ledger.
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):ledger_hash(string — hash; optional): A 32-byte hex string for the ledger version to use. (See Specifying Ledgers).ledger_index(number or string; optional): The ledger index of the ledger to use, or a shortcut string to choose a ledger automatically. (See Specifying Ledgers).transactions(boolean; optional): Iftrue, return information on transactions in the specified ledger version. The default isfalse. Ignored if you did not specify a ledger version.expand(boolean; optional): Provide full JSON-formatted information for transaction/account information instead of only hashes. The default isfalse. Ignored unless you request transactions, accounts, or both.owner_funds(boolean; optional): Iftrue, includeowner_fundsfield in the metadata of OfferCreate transactions in the response. The default isfalse. Ignored unless transactions are included andexpandistrue.binary(boolean; optional): Iftrue, andtransactionsandexpandare both alsotrue, return transaction information in binary format (hexadecimal string) instead of JSON format.queue(boolean; optional): Iftrue, and the command is requesting thecurrentledger, includes an array of queued transactions in the results.
Returns
The response follows the standard format, with a successful result containing information about the ledger, including the following fields:
ledger(object): The complete ledger header data of this ledger, with some additional fields added for convenience.ledger.account_hash(string): Hash of all account state information in this ledger, as hexadecimal.ledger.close_flags(number): A bit-map of flags relating to the closing of this ledger.ledger.close_time(number): The time this ledger was closed, in seconds since the Ripple Epoch.ledger.close_time_human(string): The time this ledger was closed, in human-readable format. Always uses the UTC time zone.ledger.close_time_resolution(number): Ledger close times are rounded to within this many seconds.ledger.closed(boolean): Whether this ledger has been closed or not.ledger.ledger_hash(string): Unique identifying hash of the entire ledger.ledger.ledger_index(string — API v1; number — API v2): The Ledger Index of this ledger.ledger.parent_close_time(number): The time at which the previous ledger was closed.ledger.parent_hash(string): The unique identifying hash of the ledger that came immediately before this one, as hexadecimal.ledger.total_coins(string): Total number of XRP drops in the network, as a quoted integer. (This decreases as transaction costs destroy XRP.)ledger.transaction_hash(string): Hash of the transaction information included in this ledger.ledger.transactions(array; optional): Transactions applied in this ledger version. By default, members are the transactions’ identifying Hash strings. If the request specifiedexpandastrue, members are full representations of the transactions instead, in either JSON or binary depending on whether the request specifiedbinaryastrue.ledger_hash(string): The unique identifying hash of the entire ledger, as hexadecimal.ledger_index(number): The Ledger Index of this ledger.validated(boolean; optional): Iftrue, this is a validated ledger version. If omitted or set tofalse, this ledger’s data is not final.queue_data(array; optional): (Omitted unless requested with thequeueparameter) Array of objects describing queued transactions, in the same order as the queue. If the request specifiedexpandastrue, members contain full representations of the transactions, in either JSON or binary depending on whether the request specifiedbinaryastrue.
Each member of the queue_data array represents one transaction in the queue. Some fields of this object may be omitted because they have not yet been calculated. The fields of this object are as follows:
account(string): The Address of the sender for this queued transaction.tx(string or object): By default, this is a string containing the identifying hash of the transaction. If transactions are expanded in binary format, this is an object whose only field istx_blob, containing the binary form of the transaction as a decimal string. If transactions are expanded in JSON format, this is an object containing the transaction object including the transaction's identifying hash in thehashfield.retries_remaining(number): How many times this transaction can be retried before being dropped.preflight_result(string): The tentative result from preliminary transaction checking. This is alwaystesSUCCESS.last_result(string; optional): If this transaction was left in the queue after getting a retriable (ter) result, this is the exactterresult code it got.auth_change(boolean; optional): Whether this transaction changes this address's ways of authorizing transactions.fee(string; optional): The Transaction Cost of this transaction, in drops of XRP.fee_level(string; optional): The transaction cost of this transaction, relative to the minimum cost for this type of transaction, in fee levels.max_spend_drops(string; optional): The maximum amount of XRP, in drops, this transaction could potentially send or destroy.
If the request specified "owner_funds": true and expanded transactions, the response has a field owner_funds in the metaData object of each OfferCreate transaction. The purpose of this field is to make it easier to track the funding status of offers with each new validated ledger. This field is defined slightly differently than the version of this field in Order Book subscription streams:
owner_funds(string): Numeric amount of theTakerGetscurrency that theAccountsending this OfferCreate transaction has after the execution of all transactions in this ledger. This does not check whether the currency amount is frozen.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "ledger",
"params": [
{
"ledger_index": "validated",
"transactions": false,
"expand": false,
"owner_funds": false
}
]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"ledger": {
"account_hash": "E8C6EF996B38EFC2E297B3165F6B687433B1DF137BDCF804C0B0F9E393E0D045",
"close_flags": 0,
"close_time": 816442750,
"close_time_human": "2025-Nov-14 13:39:10.000000000 UTC",
"close_time_iso": "2025-11-14T13:39:10Z",
"close_time_resolution": 10,
"closed": true,
"ledger_hash": "344AC8FCFC579E9EAC59CAFEBCC1E2EA36A261F4EB2A6CC649380C351F402397",
"ledger_index": "100204822",
"parent_close_time": 816442741,
"parent_hash": "ADA5D8A5A554881A9E45A8EC88FBDADD5D4D47213F0FFBCE23001AD7E37B5768",
"total_coins": "99985759346884737",
"transaction_hash": "03E26EC74BFBEEFEBD19FD512A16809C1A165B1A2F9CFF4BFD987994FCA60334"
},
"ledger_hash": "344AC8FCFC579E9EAC59CAFEBCC1E2EA36A261F4EB2A6CC649380C351F402397",
"ledger_index": 100204822,
"status": "success",
"validated": true
}
}
ledger_closed
Retrieves the latest closed ledger version.
The ledger_closed method returns the unique identifiers of the most recently closed ledger. (This ledger is not necessarily validated and immutable yet.)
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): none.
Returns
The response follows the standard format, with a successful result containing the following fields:
ledger_hash(string): The unique Hash of this ledger version, in hexadecimal.ledger_index(unsigned integer): The ledger index of this ledger version.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "ledger_closed",
"params": [
{}
]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"ledger_hash": "3E6CF37B032E232ED6D77900C937647A275C8FE1F9F784F361B1022BB4608172",
"ledger_index": 100204931,
"status": "success"
}
}
ledger_current
Retrieves the current working ledger version.
The ledger_current method returns the unique identifiers of the current in-progress ledger. This command is mostly useful for testing, because the ledger returned is still in flux.
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): none.
Returns
The response follows the standard format, with a successful result containing the following field:
ledger_current_index(unsigned integer — ledger index): The ledger index of this ledger version.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "ledger_current",
"params": [
{}
]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"ledger_current_index": 100205074,
"status": "success"
}
}
ledger_data
Retrieves the raw contents of a ledger version.
The ledger_data method retrieves contents of the specified ledger. You can iterate through several calls to retrieve the entire contents of a single ledger version.
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):ledger_hash(string — hash; optional): A 20-byte hex string identifying the ledger version to use.ledger_index(number or string; optional): The ledger index of the ledger to use, or a shortcut string to choose a ledger automatically. (See Specifying Ledgers.)binary(boolean; optional): Iftrue, return ledger entries as hexadecimal strings instead of JSON. The default isfalse.limit(number; optional): Limit the number of ledger entries to retrieve. The server may return fewer than this number of entries. Cannot be more than 2048 (when requesting binary) or 256 (when requesting JSON). Positive values outside this range are replaced with the closest valid option. The default is the maximum.marker(string — marker; optional): Value from a previous paginated response. Resume retrieving data where that response left off.type(string; optional): Filter results to a specific type of ledger entry. This field accepts canonical names of ledger entry types (case-insensitive) or short names. If omitted, return ledger entries of all types.
Returns
The response follows the standard format, with a successful result containing the following fields:
ledger_index(unsigned integer — ledger index): The ledger index of this ledger version.ledger_hash(string — hash): Unique identifying hash of this ledger version.state(array): Array of JSON objects containing data from the ledger's state tree, as defined below.marker(string — marker): Server-defined value indicating the response is paginated. Pass this to the next call to resume where this call left off.
If a type field is mentioned in the request, the state array will be empty if the first set of array objects does not match the type requested. In such cases, you can use the marker from this response to paginate and retrieve further data.
The format of each object in the state array depends on whether binary was set to true or not in the request. Each state object may include the following fields:
data(string): (Only included if"binary": true) Hex representation of the requested data.LedgerEntryType(string): (Only included if"binary": false) String indicating what type of ledger object this object represents. See ledger object types for the full list.- (Additional fields) (various): (Only included if
"binary": false) Additional fields describing this object, depending on which ledger object type it is. index(string): Unique identifier for this ledger entry, as hex.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "ledger_data",
"params": [
{
"binary": true,
"ledger_hash": "842B57C1CC0613299A686D3E9F310EC0422C84D3911E5056389AA7E5808A93C8",
"limit": 5
}
]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"error": "lgrNotFound",
"error_code": 21,
"error_message": "ledgerNotFound",
"request": {
"binary": true,
"command": "ledger_data",
"ledger_hash": "842B57C1CC0613299A686D3E9F310EC0422C84D3911E5056389AA7E5808A93C8",
"limit": 5
},
"status": "error"
}
}