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-KeystringThe apiKey allows you to authenticate on the API (optional)
Query Parameters
fromChainstringrequiredSource chain ID
fromTokenstringrequiredSource token address (use "0x0000…" for native token)
toChainstringrequiredDestination chain ID
toTokenstringrequiredDestination token address
fromAmountstringrequiredAmount to swap (with decimals, as string)
fromAddressstringSender wallet address
toAddressstringRecipient wallet address
slippagenumberSlippage tolerance (0.005 = 0.5%, default: 0.005)
allowBridgesstringComma-separated list of allowed bridges
denyBridgesstringComma-separated list of denied bridges
Response
Status Code: 200 OK
Content Type: application/json
Response
idstringrequiredUnique route identifier
typestringrequiredRoute type (e.g., "lifi")
toolstringrequiredBridge or DEX used for this route
keystringrequiredTool identifier
namestringrequiredTool name
logoURIstringTool logo URL
fromChainIdstringrequiredSource chain ID
toChainIdstringrequiredDestination chain ID
fromTokenobjectrequiredSource token information
toTokenobjectrequiredDestination token information
fromAmountstringrequiredAmount to send (with decimals)
slippagenumberSlippage tolerance
fromAmountstringrequiredAmount to send
toAmountstringrequiredExpected amount to receive
toAmountMinstringrequiredMinimum amount to receive (considering slippage)
approvalAddressstringAddress to approve tokens to (if needed)
executionDurationnumberEstimated execution time in seconds
feeCostsobject[]Array of fee costs
gasCostsobject[]Array of gas costs
fromstringrequiredSender address
tostringrequiredContract address to send transaction to
chainIdstringrequiredChain ID
datastringrequiredTransaction data (hex)
valuestringrequiredValue to send (hex)
gasPricestringGas price (hex)
gasLimitstringGas 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'
)