> For the complete documentation index, see [llms.txt](https://docs.squidrouter.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.squidrouter.com/api-and-sdk-integration/chain-integration-guides/xrpl-integration/api-and-sdk.md).

# API & SDK

Integrate XRPL cross-chain swaps directly using Squid's routing API or TypeScript SDK. This gives you full control over the swap lifecycle — routing, execution, and status tracking — so you can build custom UIs or backend flows.

***

## API Integration

### Route to XRPL (EVM → XRPL)

To route from an EVM chain to XRPL, set `toChain` to `xrpl-mainnet` and `toToken` to one of the supported XRPL token addresses.

```typescript
const params = {
  fromAddress: "0xYourEVMAddress",
  fromChain: "8453",                  // Base
  fromToken: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",  // ETH
  fromAmount: "1000000000000000",      // Amount in wei
  toChain: "xrpl-mainnet",
  toToken: "xrp",
  toAddress: "YourXRPLAddress",
  quoteOnly: false,
};

const routeResult = await axios.post(
  "https://v2.api.squidrouter.com/v2/route",
  params,
  {
    headers: {
      "x-integrator-id": "<your-integrator-id>",
      "Content-Type": "application/json",
    },
  }
);

const route = routeResult.data.route;
const quoteId = route.quoteId;  // Required for status tracking
```

**Transaction type:** `DEPOSIT_ADDRESS_CALLDATA` — The route response will include a deposit address and calldata. Transfer the specified amount to the deposit address to initiate the swap.

### Same-Chain Swap on XRPL (XRPL → XRPL)

You can also perform same-chain swaps between XRPL tokens.

```typescript
const params = {
  fromAddress: "YourXRPLAddress",
  fromChain: "xrpl-mainnet",
  fromToken: "xrp",
  fromAmount: "10000000",             // Amount in drops (10 XRP)
  toChain: "xrpl-mainnet",
  toToken: "524c555344000000000000000000000000000000.rmxckbedwqr76quhesumdegf4b9xj8m5de", // RLUSD
  toAddress: "rYourXRPLAddress",
  quoteOnly: false,
};
```

**Transaction type:** `DEPOSIT_ADDRESS_CALLDATA`

### Route from XRPL (XRPL → EVM)

To route from XRPL to an EVM chain, set `fromChain` to `xrpl-mainnet`.

```typescript
const params = {
  fromAddress: "YourXRPLAddress",
  fromChain: "xrpl-mainnet",
  fromToken: "xrp",
  fromAmount: "10000000",             // Amount in drops (10 XRP)
  toChain: "42161",                   // Arbitrum
  toToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",  // USDC
  toAddress: "0xYourEVMAddress",
  quoteOnly: false,
};
```

**Transaction type:** `DEPOSIT_ADDRESS_CALLDATA`

### API Code Examples

| Route       | Example                                                                                       |
| ----------- | --------------------------------------------------------------------------------------------- |
| EVM → XRPL  | [baseToXrplSwap](https://github.com/0xsquid/examples/tree/main/V2/api/baseToXrplSwap)         |
| XRPL → XRPL | [xrplSameChainSwap](https://github.com/0xsquid/examples/tree/main/V2/api/xrplSameChainSwap)   |
| XRPL → EVM  | [xrplToArbitrumSwap](https://github.com/0xsquid/examples/tree/main/V2/api/xrplToArbitrumSwap) |

***

## SDK Integration

The Squid SDK provides the same XRPL routing capabilities. After initializing the SDK with your integrator ID, use `squid.route()` with the same parameters as the API examples above, then execute using the returned transaction request.

For full SDK setup and execution details, see the [SDK documentation](/api-and-sdk-integration/sdk.md).

### SDK Code Examples

| Route       | Example                                                                                       |
| ----------- | --------------------------------------------------------------------------------------------- |
| EVM → XRPL  | [baseToXrplSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/baseToXrplSwap)         |
| XRPL → XRPL | [xrplSameChainSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/xrplSameChainSwap)   |
| XRPL → EVM  | [xrplToArbitrumSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/xrplToArbitrumSwap) |

***

## Status Tracking

XRPL routes are powered by Squid Intents, which **requires** the `quoteId` for status polling. The `quoteId` is returned in the route response.

```typescript
const getStatus = async (params) => {
  const result = await axios.get("https://v2.api.squidrouter.com/v2/status", {
    params: {
      transactionId: params.transactionId,
      fromChainId: params.fromChainId,
      toChainId: params.toChainId,
      quoteId: params.quoteId,  // Required for Squid Intents
    },
    headers: {
      "x-integrator-id": "<your-integrator-id>",
    },
  });
  return result.data;
};
```

> **Important:** A Squid Intent transaction will fail unless status is polled with the `quoteId`. See the [Integrating Squid Intents](/api-and-sdk-integration/coral-intent-swaps/integrating-squid-intents.md) guide for full status polling details.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.squidrouter.com/api-and-sdk-integration/chain-integration-guides/xrpl-integration/api-and-sdk.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
