account_currencies - XRPL
This method retrieves a list of currencies that an account can send or receive, based on its trust lines.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | string | Yes | Account address |
| ledger_hash | string | No | Ledger hash |
| ledger_index | string/number | No | Ledger index or shortcut |
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_currencies",
"params": [{
"account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"ledger_index": "validated"
}],
"id": "getblock.io"
}'example.js
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_currencies',
params: [{
account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
ledger_index: 'validated'
}],
id: 'getblock.io'
};
axios.post(url, payload, { headers })
.then(response => console.log(response.data))
.catch(error => console.error(error));example.py
pythonimport requests
url = "https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/"
headers = {
"Content-Type": "application/json"
}
payload = {
"jsonrpc": "2.0",
"method": "account_currencies",
"params": [{
"account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"ledger_index": "validated"
}],
"id": "getblock.io"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())main.rs
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_currencies",
"params": [{
"account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"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
response.json
json{
"result": {
"ledger_index": 63631836,
"receive_currencies": ["USD", "EUR", "BTC"],
"send_currencies": ["USD", "EUR"],
"status": "success",
"validated": true
}
}Response Parameters
| Parameter | Type | Description |
|---|---|---|
| receive_currencies | array | Receivable currencies |
| send_currencies | array | Sendable currencies |
| ledger_index | integer | Ledger index used |
Use Cases
- Check supported currencies
- Build currency selection UIs
- Validate payment paths
Error Handling
| Error Code | Description |
|---|---|
| actNotFound | Account not found |
| invalidParams | Invalid parameters |
SDK Integration
xrpl.js example
javascriptconst xrpl = require('xrpl');
async function getCurrencies() {
const client = new xrpl.Client('wss://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>');
await client.connect();
const response = await client.request({
command: 'account_currencies',
account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59'
});
console.log('Can receive:', response.result.receive_currencies);
await client.disconnect();
}
getCurrencies();xrpl-py example
pythonfrom xrpl.clients import JsonRpcClient
from xrpl.models.requests import AccountCurrencies
client = JsonRpcClient("https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>")
request = AccountCurrencies(account="r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59")
response = client.request(request)
print(response.result)