# ripple_path_find - XRPL

> Example code for the ripple_path_find JSON RPC method. Complete guide to using ripple_path_find JSON-RPC in the GetBlock Web3 documentation.

This method is a simplified version of `path_find` that searches for a path one time and returns results immediately.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| source_account | string | Yes | Sending account |
| destination_account | string | Yes | Receiving account |
| destination_amount | object | Yes | Amount to receive |
| send_max | object | No | Maximum to send |
| source_currencies | array | No | Currencies to use |
| ledger_hash | string | No | Ledger hash |
| ledger_index | string/number | No | Ledger index |

## Request Example

#### cURL

#### cURL

```bash
curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ripple_path_find",
    "params": [{
        "source_account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
        "destination_amount": {
            "currency": "USD",
            "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
            "value": "100"
        }
    }],
    "id": "getblock.io"
}'
```

#### JavaScript (Axios)

#### example.js

```javascript
const 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: 'ripple_path_find',
    params: [{
        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));
```

#### Python

#### example.py

```python
import requests

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

payload = {
    "jsonrpc": "2.0",
    "method": "ripple_path_find",
    "params": [{
        "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())
```

#### Rust

#### main.rs

```rust
use 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": "ripple_path_find",
        "params": [{
            "source_account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
            "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
            "destination_amount": {
                "currency": "USD",
                "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
                "value": "100"
            }
        }],
        "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": {
        "alternatives": [
            {
                "paths_canonical": [],
                "paths_computed": [
                    [
                        {
                            "currency": "USD",
                            "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
                            "type": 48
                        }
                    ]
                ],
                "source_amount": "83088782"
            }
        ],
        "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
        "destination_amount": {
            "currency": "USD",
            "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
            "value": "100"
        },
        "destination_currencies": [
            "USD",
            "XRP"
        ],
        "full_reply": true,
        "source_account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "status": "success"
    }
}
```

## Returns

| Field | Type | Description |
| --- | --- | --- |
| alternatives | array | Payment paths found |
| destination_account | string | Destination |
| destination_currencies | array | Available currencies |

## Use Cases

* One-time path queries
* Payment validation
* Quote generation

## SDK Integration

### xrpl.js

#### xrpl-path-find.js

```javascript
const xrpl = require('xrpl');

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

ripplePathFind();
```
