path_find - XRPL

This method searches for a path along which a payment can be made, and periodically sends updates when the path changes.

Parameters

ParameterTypeRequiredDescription
subcommandstringYes"create", "close", or "status"
source_accountstringYesSending account
destination_accountstringYesReceiving account
destination_amountobjectYesAmount to receive
send_maxobjectNoMaximum to send
source_currenciesarrayNoCurrencies to use

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": "path_find",
    "params": [{
        "subcommand": "create",
        "source_account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
        "destination_amount": {
            "currency": "USD",
            "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
            "value": "100"
        }
    }],
    "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: 'path_find',
    params: [{
        subcommand: 'create',
        source_account: 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH',
        destination_account: 'ra5nK24KXen9AHvsdFTKHSANinZseWnPcX',
        destination_amount: {
            currency: 'USD',
            issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
            value: '100'
        }
    }],
    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": "path_find",
    "params": [{
        "subcommand": "create",
        "source_account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
        "destination_amount": {
            "currency": "USD",
            "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
            "value": "100"
        }
    }],
    "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": "path_find",
        "params": [{
            "subcommand": "create",
            "source_account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
            "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
            "destination_amount": {
                "currency": "USD",
                "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
                "value": "100"
            }
        }],
        "id": "getblock.io"
    });

    let response = client
        .post("hhttps://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 Example (JSON)

json{
    "result": {
        "alternatives": [
            {
                "paths_computed": [
                    [{"currency": "USD", "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"}]
                ],
                "source_amount": "1000000"
            }
        ],
        "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
        "destination_amount": {
            "currency": "USD",
            "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
            "value": "100"
        },
        "status": "success"
    }
}

Returns

FieldTypeDescription
alternativesarrayPayment paths found
destination_accountstringDestination
destination_amountobjectAmount

Use Cases

  • Cross-currency payments
  • Find best exchange rates
  • Payment routing

SDK Integration

javascriptconst xrpl = require('xrpl');

async function findPath() {
    const client = new xrpl.Client('wss://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>');
    await client.connect();
    
    const response = await client.request({
        command: 'path_find',
        subcommand: 'create',
        source_account: 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH',
        destination_account: 'ra5nK24KXen9AHvsdFTKHSANinZseWnPcX',
        destination_amount: {
            currency: 'USD',
            issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
            value: '100'
        }
    });
    
    console.log('Paths:', response.result.alternatives);
    await client.disconnect();
}

findPath();