account_info - XRPL

This method retrieves information about an account, its activity, and its XRP balance. All information retrieved is relative to a specific ledger version.

Parameters

ParameterTypeRequiredDescription
accountstringYesAccount address
ledger_hashstringNo64-character hex ledger hash
ledger_indexstring/numberNoLedger index or shortcut
queuebooleanNoInclude queued transactions
signer_listsbooleanNoInclude signer lists

Request Example

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "account_info",
    "params": [{
        "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "ledger_index": "validated"
    }],
    "id": "getblock.io"
}'
javascriptconst axios = require('axios');

const url = 'https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/';
const headers = {
    'Content-Type': 'application/json'
};

const payload = {
    jsonrpc: '2.0',
    method: 'account_info',
    params: [{
        account: 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH',
        ledger_index: 'validated'
    }],
    id: 'getblock.io'
};

axios.post(url, payload, { headers })
    .then(response => console.log(response.data))
    .catch(error => console.error(error));
pythonimport requests

url = "https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/"
headers = {
    "Content-Type": "application/json"
}

payload = {
    "jsonrpc": "2.0",
    "method": "account_info",
    "params": [{
        "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "ledger_index": "validated"
    }],
    "id": "getblock.io"
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
rustuse reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let payload = json!({
        "jsonrpc": "2.0",
        "method": "account_info",
        "params": [{
            "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
            "ledger_index": "validated"
        }],
        "id": "getblock.io"
    });

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&payload)
        .send()
        .await?;

    let result: serde_json::Value = response.json().await?;
    println!("{:#?}", result);
    
    Ok(())
}

Response Example

json{
    "result": {
        "account_data": {
            "Account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
            "Balance": "1070051282",
            "Flags": 0,
            "LedgerEntryType": "AccountRoot",
            "OwnerCount": 0,
            "PreviousTxnID": "8CA6DE7FCB677A4E59D34B782AF47298E8426E4C1F5774CD0F0185664C68CE52",
            "PreviousTxnLgrSeq": 100788827,
            "Sequence": 45,
            "index": "B1CB040A17F9469BC00376EC8719535655824AD16CB5F539DD5765FEA88FDBE3"
        },
        "account_flags": {
            "allowTrustLineClawback": false,
            "defaultRipple": false,
            "depositAuth": false,
            "disableMasterKey": false,
            "disallowIncomingCheck": false,
            "disallowIncomingNFTokenOffer": false,
            "disallowIncomingPayChan": false,
            "disallowIncomingTrustline": false,
            "disallowIncomingXRP": false,
            "globalFreeze": false,
            "noFreeze": false,
            "passwordSpent": false,
            "requireAuthorization": false,
            "requireDestinationTag": false
        },
        "ledger_hash": "2F1865AEA9A70D048D491819D76CBB3F1B6FA567B03A7411BACFED0043A11342",
        "ledger_index": 102053337,
        "status": "success",
        "validated": true
    }
}

Response Parameters

ParameterTypeDescription
AccountstringAccount address
BalancestringXRP balance in drops
FlagsnumberAccount flags
OwnerCountnumberObjects owned
SequencenumberNext transaction sequence
account_dataobjectAccount information object
ledger_current_indexintegerCurrent ledger index
validatedbooleanWhether ledger is validated

Use Cases

  • Check XRP balance
  • Verify account exists
  • Get account sequence for transactions
  • Monitor account settings

Error Handling

Error CodeDescription
actNotFoundAccount not found
invalidParamsInvalid parameters

SDK Integration

javascriptconst xrpl = require('xrpl');

async function getAccountInfo() {
    const client = new xrpl.Client('wss://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>');
    await client.connect();
    
    const response = await client.request({
        command: 'account_info',
        account: 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH',
        ledger_index: 'validated'
    });
    
    console.log('Balance:', xrpl.dropsToXrp(response.result.account_data.Balance), 'XRP');
    await client.disconnect();
}

getAccountInfo();
pythonfrom xrpl.clients import JsonRpcClient
from xrpl.models.requests import AccountInfo

client = JsonRpcClient("https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>")

request = AccountInfo(
    account="rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
    ledger_index="validated"
)

response = client.request(request)
print(response.result)