account_tx
The account_tx
method retrieves a list of validated transactions that involve a given account.
Request Format
An example of the request format:
{ "id": 2, "command": "account_tx", "account": "rLNaPoKeeBjZe2qs6x52yVPZpZ8td4dc6w", "ledger_index_min": -1, "ledger_index_max": -1, "binary": false, "limit": 2, "forward": false }
The request includes the following parameters:
Field | Type | Description |
---|---|---|
account | String | A unique identifier for the account, most commonly the account's address. |
tx_type | String | (Optional) Clio Only Return only transactions of a specific type, such as "Clawback", "AccountSet", "AccountDelete", et al. Case-insensitive. See Transaction Types. New in: Clio v2.0 AMM support since: Clio v2.1.0 |
ledger_index_min | Integer | API v1: (Optional) Use to specify the earliest ledger to include transactions from. A value of -1 instructs the server to use the earliest validated ledger version available.API v2: Identical to v1, but also returns a lgrIdxMalformed error if a value is specified beyond the range of ledgers the server has. |
ledger_index_max | Integer | API v1: (Optional) Use to specify the most recent ledger to include transactions from. A value of -1 instructs the server to use the most recent validated ledger version available.API v2: Identical to v1, but also returns a lgrIdxMalformed error if a value is specified beyond the range of ledgers the server has. |
ledger_hash | String | (Optional) Use to look for transactions from a single ledger only. (See Specifying Ledgers.) |
ledger_index | String or Unsigned Integer | (Optional) Use to look for transactions from a single ledger only. (See Specifying Ledgers.) |
binary | Boolean | API v1: (Optional) Defaults to false . If set to true , returns transactions as hex strings instead of JSON.API v2: Identical to v1, but also returns an invalidParams error if you provide a non-boolean value. |
forward | Boolean | API v1: (Optional) Defaults to false . If set to true , returns values indexed with the oldest ledger first. Otherwise, the results are indexed with the newest ledger first. (Each page of results may not be internally ordered, but the pages are overall ordered.)API v2: Identical to v1, but also returns an invalidParams error if you provide a non-boolean value. |
limit | Integer | (Optional) Default varies. Limit the number of transactions to retrieve. The server is not required to honor this value. |
marker | Marker | Value from a previous paginated response. Resume retrieving data where that response left off. This value is stable even if there is a change in the server's range of available ledgers. |
- You must use at least one of the following fields in your request:
ledger_index
,ledger_hash
,ledger_index_min
, orledger_index_max
. - API v2: If you specify either
ledger_index
orledger_hash
, includingledger_index_min
andledger_index_max
returns aninvalidParams
error.
Iterating over queried data
As with other paginated methods, you can use the marker
field to return multiple pages of data.
In the time between requests, "ledger_index_min": -1
and "ledger_index_max": -1
may change to refer to different ledger versions than they did before. The marker
field can safely paginate even if there are changes in the ledger range from the request, so long as the marker does not indicate a point outside the range of ledgers specified in the request.
Response Format
An example of a successful response:
{ "id": 2, "result": { "account": "rLNaPoKeeBjZe2qs6x52yVPZpZ8td4dc6w", "ledger_index_max": 57111999, "ledger_index_min": 55886305, "limit": 2, "marker": { "ledger": 57111981, "seq": 16 }, "transactions": [ { "meta": { "AffectedNodes": [ { "ModifiedNode": { "FinalFields": { "Account": "rLNaPoKeeBjZe2qs6x52yVPZpZ8td4dc6w", "Balance": "3732969177079", "Flags": 131072, "OwnerCount": 0, "Sequence": 702817 }, "LedgerEntryType": "AccountRoot", "LedgerIndex": "140FA03FE8C39540CA8189BC7A7956795C712BC0A542C6409C041150703C8574", "PreviousFields": { "Balance": "3713891690008" }, "PreviousTxnID": "D58864C16344ADCC15995C7986CFC607CB693E88F84D2E019F0A35FB29749202", "PreviousTxnLgrSeq": 57111994 } }, { "ModifiedNode": { "FinalFields": { "Account": "rw2ciyaNshpHe7bCHo4bRWq6pqqynnWKQg", "Balance": "40010160", "Flags": 131072, "OwnerCount": 0, "Sequence": 466334 }, "LedgerEntryType": "AccountRoot", "LedgerIndex": "CC20FEBEA6D2AF969EC46F2BD92684D9FBABC3F238E841B5E056FE4EBF4379A9", "PreviousFields": { "Balance": "19117497271", "Sequence": 466333 }, "PreviousTxnID": "F6B8274D3D419A95A59681E5F55578084C395FF9051924360CA3EA745F5581E8", "PreviousTxnLgrSeq": 57111993 } } ], "TransactionIndex": 25, "TransactionResult": "tesSUCCESS", "delivered_amount": "19077487071" }, "tx": { "Account": "rw2ciyaNshpHe7bCHo4bRWq6pqqynnWKQg", "Amount": "19077487071", "Destination": "rLNaPoKeeBjZe2qs6x52yVPZpZ8td4dc6w", "DestinationTag": 1, "Fee": "40", "Flags": 2147483648, "LastLedgerSequence": 57112020, "Sequence": 466333, "SigningPubKey": "0381575032E254BF4D699C3D8D6EFDB63B3A71F97475C6F6885BC7DAEEE55D9A01", "TransactionType": "Payment", "TxnSignature": "3045022100CFC5FD057C7C685C690637AD1E639E2642BBC00EFD8E06E3F6C72FA924BC99D40220317D0708E814F69F874D641B6732E37A53B1220B493B2B8390D9EF51E8062515", "date": 649200260, "hash": "46BF0B576677B0DEA2D94591424A57A2DE8E3D89383631E16F40D09A513C656C", "inLedger": 57111998, "ledger_index": 57111998 }, "validated": true }, { "meta": { "AffectedNodes": [ { "ModifiedNode": { "FinalFields": { "Account": "rLNaPoKeeBjZe2qs6x52yVPZpZ8td4dc6w", "Balance": "3713891690008", "Flags": 131072, "OwnerCount": 0, "Sequence": 702817 }, "LedgerEntryType": "AccountRoot", "LedgerIndex": "140FA03FE8C39540CA8189BC7A7956795C712BC0A542C6409C041150703C8574", "PreviousFields": { "Balance": "3714441690048", "Sequence": 702816 }, "PreviousTxnID": "FDD5007913B39027BAF10B31144DBC1F7DC147528DF31FF048A06DC5D3108BD6", "PreviousTxnLgrSeq": 57111981 } }, { "ModifiedNode": { "FinalFields": { "Account": "r9dU6Z7P2i7MrDi1VUZ7uyq6J77eg86YtB", "Balance": "2629998983", "Flags": 0, "OwnerCount": 0, "Sequence": 10 }, "LedgerEntryType": "AccountRoot", "LedgerIndex": "27B96FE681B33825CC95DA197358B30D3A1721F2125F2D76022D46B2418ABA0A", "PreviousFields": { "Balance": "2079998983" }, "PreviousTxnID": "44A47AC04C0C7237C32BE9A532B578D07641705D3A59DB9B3C5B6225001E39B7", "PreviousTxnLgrSeq": 56613857 } } ], "TransactionIndex": 16, "TransactionResult": "tesSUCCESS", "delivered_amount": "550000000" }, "tx": { "Account": "rLNaPoKeeBjZe2qs6x52yVPZpZ8td4dc6w", "Amount": "550000000", "Destination": "r9dU6Z7P2i7MrDi1VUZ7uyq6J77eg86YtB", "Fee": "40", "Flags": 2147483648, "LastLedgerSequence": 57112016, "Sequence": 702816, "SigningPubKey": "020A46D8D02AC780C59853ACA309EAA92E7D8E02DD72A0B6AC315A7D18A6C3276A", "TransactionType": "Payment", "TxnSignature": "3045022100D589029EF63F9E528F6100C7A36D26AFFF84085EC9AC16DA8E30E11F390D4E87022011466E0FE4A90B89142EE47E535545EEA4A2D65E0BD234DFB447721218B59C9B", "date": 649200241, "hash": "D58864C16344ADCC15995C7986CFC607CB693E88F84D2E019F0A35FB29749202", "inLedger": 57111994, "ledger_index": 57111994 }, "validated": true } ], "validated": true }, "status": "success", "type": "response" }
The response follows the standard format, with a successful result containing the following fields:
Field | Type | Description |
---|---|---|
account | String | Unique Address identifying the related account |
ledger_index_min | Integer - Ledger Index | The ledger index of the earliest ledger actually searched for transactions. |
ledger_index_max | Integer - Ledger Index | The ledger index of the most recent ledger actually searched for transactions. |
limit | Integer | The limit value used in the request. (This may differ from the actual limit value enforced by the server.) |
marker | Marker | Server-defined value indicating the response is paginated. Pass this to the next call to resume where this call left off. |
transactions | Array | Array of transactions matching the request's criteria, as explained below. |
validated | Boolean | If included and set to true , the information in this response comes from a validated ledger version. Otherwise, the information is subject to change. |
Note: The server may respond with different values of ledger_index_min
and ledger_index_max
than you provided in the request, for example if it did not have the versions you specified on hand.
Each transaction object includes the following fields, depending on whether it was requested in JSON or hex string ("binary":true
) format.
Field | Type | Description |
---|---|---|
ledger_index | Integer | The ledger index of the ledger version that included this transaction. |
meta | Object (JSON) or String (Binary) | If binary is True, then this is a hex string of the transaction metadata. Otherwise, the transaction metadata is included in JSON format. |
tx | Object | (JSON mode only) JSON object defining the transaction |
tx_blob | String | (Binary mode only) Unique hashed String representing the transaction. |
validated | Boolean | Whether or not the transaction is included in a validated ledger. Any transaction not yet in a validated ledger is subject to change. |
Possible Errors
- Any of the universal error types.
invalidParams
- One or more fields are specified incorrectly, or one or more required fields are missing.actMalformed
- The Address specified in theaccount
field of the request is not formatted properly.lgrIdxMalformed
- The ledger specified by theledger_index_min
orledger_index_max
does not exist, or if it does exist but the server does not have it.lgrIdxsInvalid
- Either the request specifies aledger_index_max
that is before theledger_index_min
, or the server does not have a validated ledger range because it is not synced with the network.