Skip to main content

Single Quote

Get the best single route for a token swap or bridge operation. This endpoint returns the optimal route based on output amount.

If you want to learn more about how to use this endpoint, please have a look at our guide.

API

Endpoint Details

GET /v1/quote

Get the best single route for a token swap or bridge operation. This endpoint returns the optimal route based on output amount.

Request

Headers

X-API-Keystring

The apiKey allows you to authenticate on the API (optional)

Query Parameters

fromChainstringrequired

Source chain ID

Example: 1
fromTokenstringrequired

Source token address (use "0x0000…" for native token)

Example: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
toChainstringrequired

Destination chain ID

Example: 137
toTokenstringrequired

Destination token address

Example: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
fromAmountstringrequired

Amount to swap (with decimals, as string)

Example: 1000000
fromAddressstring

Sender wallet address

Example: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb
toAddressstring

Recipient wallet address

Example: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb
slippagenumber

Slippage tolerance (0.005 = 0.5%, default: 0.005)

Example: 0.005
allowBridgesstring

Comma-separated list of allowed bridges

Example: stargate,across
denyBridgesstring

Comma-separated list of denied bridges

Example: hop

Response

Status Code: 200 OK
Content Type: application/json

Response

idstringrequired

Unique route identifier

typestringrequired

Route type (e.g., "lifi")

toolstringrequired

Bridge or DEX used for this route

toolDetailsobject

Details about the tool used

keystringrequired

Tool identifier

namestringrequired

Tool name

logoURIstring

Tool logo URL

actionobjectrequired

Swap action details

fromChainIdstringrequired

Source chain ID

toChainIdstringrequired

Destination chain ID

fromTokenobjectrequired

Source token information

toTokenobjectrequired

Destination token information

fromAmountstringrequired

Amount to send (with decimals)

slippagenumber

Slippage tolerance

estimateobjectrequired

Route estimate details

fromAmountstringrequired

Amount to send

toAmountstringrequired

Expected amount to receive

toAmountMinstringrequired

Minimum amount to receive (considering slippage)

approvalAddressstring

Address to approve tokens to (if needed)

executionDurationnumber

Estimated execution time in seconds

feeCostsobject[]

Array of fee costs

gasCostsobject[]

Array of gas costs

transactionRequestobject

Transaction data ready to be sent

fromstringrequired

Sender address

tostringrequired

Contract address to send transaction to

chainIdstringrequired

Chain ID

datastringrequired

Transaction data (hex)

valuestringrequired

Value to send (hex)

gasPricestring

Gas price (hex)

gasLimitstring

Gas limit (hex)

Example Request

curl --request GET \
--url 'https://xplore.api.v2.routerprotocol.com/v1/quote?fromChain=1&fromToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&toChain=137&toToken=0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174&fromAmount=1000000&fromAddress=0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb&toAddress=0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb' \
--header 'X-API-Key: your-api-key-here'

Example Response

Status Code: 200 OK

{
"id": "route-uuid-123",
"type": "lifi",
"tool": "stargate",
"toolDetails": {
"key": "stargate",
"name": "Stargate",
"logoURI": "https://..."
},
"action": {
"fromChainId": 1,
"toChainId": 137,
"fromToken": {
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"chainId": "1",
"symbol": "USDC",
"decimals": 6,
"name": "USD Coin",
"logoURI": "https://..."
},
"toToken": {
"address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"chainId": "137",
"symbol": "USDC",
"decimals": 6,
"name": "USD Coin",
"logoURI": "https://..."
},
"fromAmount": "1000000",
"slippage": 0.005,
"fromAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"toAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
},
"estimate": {
"fromAmount": "1000000",
"toAmount": "995000",
"toAmountMin": "990025",
"approvalAddress": "0x8731d54E9D02c286767d56ac03e8037C07e01e98",
"executionDuration": 120,
"feeCosts": [
{
"name": "Bridge Fee",
"description": "Stargate bridge fee",
"token": {
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"chainId": "1",
"symbol": "USDC",
"decimals": 6
},
"amount": "2500",
"amountUSD": "2.50",
"percentage": "0.0025",
"included": true
}
],
"gasCosts": [
{
"type": "SEND",
"price": "30000000000",
"estimate": "150000",
"limit": "200000",
"amount": "4500000000000000",
"amountUSD": "7.50",
"token": {
"address": "0x0000000000000000000000000000000000000000",
"chainId": "1",
"symbol": "ETH",
"decimals": 18,
"name": "Ether"
}
}
]
},
"transactionRequest": {
"from": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"to": "0x8731d54E9D02c286767d56ac03e8037C07e01e98",
"chainId": "1",
"data": "0x...",
"value": "0x0",
"gasPrice": "0x6fc23ac00",
"gasLimit": "0x30d40"
}
}

Using the Transaction Request

The transactionRequest object contains everything needed to execute the swap:

// Example using ethers.js
const tx = await signer.sendTransaction({
from: response.transactionRequest.from,
to: response.transactionRequest.to,
data: response.transactionRequest.data,
value: response.transactionRequest.value,
gasPrice: response.transactionRequest.gasPrice,
gasLimit: response.transactionRequest.gasLimit
});

Code Examples

JavaScript/TypeScript

async function getQuote(params: {
fromChain: string;
fromToken: string;
toChain: string;
toToken: string;
fromAmount: string;
fromAddress?: string;
toAddress?: string;
slippage?: number;
}) {
const queryParams = new URLSearchParams({
fromChain: params.fromChain,
fromToken: params.fromToken,
toChain: params.toChain,
toToken: params.toToken,
fromAmount: params.fromAmount,
});

if (params.fromAddress) queryParams.append('fromAddress', params.fromAddress);
if (params.toAddress) queryParams.append('toAddress', params.toAddress);
if (params.slippage) queryParams.append('slippage', params.slippage.toString());

const response = await fetch(
`https://xplore.api.v2.routerprotocol.com/v1/quote?${queryParams.toString()}`,
{
headers: {
'X-API-Key': 'your-api-key-here'
}
}
);

return await response.json();
}

// Usage
const quote = await getQuote({
fromChain: '1',
fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
toChain: '137',
toToken: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
fromAmount: '1000000',
});

Python

import requests

def get_quote(from_chain, from_token, to_chain, to_token, from_amount,
from_address=None, to_address=None, slippage=None):
params = {
'fromChain': from_chain,
'fromToken': from_token,
'toChain': to_chain,
'toToken': to_token,
'fromAmount': from_amount,
}

if from_address:
params['fromAddress'] = from_address
if to_address:
params['toAddress'] = to_address
if slippage:
params['slippage'] = slippage

response = requests.get(
'https://xplore.api.v2.routerprotocol.com/v1/quote',
params=params,
headers={'X-API-Key': 'your-api-key-here'}
)
return response.json()

# Usage
quote = get_quote(
from_chain='1',
from_token='0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
to_chain='137',
to_token='0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
from_amount='1000000'
)