Get Swap Quote
curl --request POST \
--url https://api.nexroute.io/v1/quote \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"tokenIn": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
"tokenOut": "0x55d398326f99059fF775485246999027B3197955",
"amountIn": "1000000000000000000"
}
'import requests
url = "https://api.nexroute.io/v1/quote"
payload = {
"tokenIn": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
"tokenOut": "0x55d398326f99059fF775485246999027B3197955",
"amountIn": "1000000000000000000"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tokenIn: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
tokenOut: '0x55d398326f99059fF775485246999027B3197955',
amountIn: '1000000000000000000'
})
};
fetch('https://api.nexroute.io/v1/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nexroute.io/v1/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'tokenIn' => '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
'tokenOut' => '0x55d398326f99059fF775485246999027B3197955',
'amountIn' => '1000000000000000000'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nexroute.io/v1/quote"
payload := strings.NewReader("{\n \"tokenIn\": \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\",\n \"tokenOut\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amountIn\": \"1000000000000000000\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nexroute.io/v1/quote")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"tokenIn\": \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\",\n \"tokenOut\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amountIn\": \"1000000000000000000\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nexroute.io/v1/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tokenIn\": \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\",\n \"tokenOut\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amountIn\": \"1000000000000000000\"\n}"
response = http.request(request)
puts response.read_body{
"amountOut": "8643194859422640072",
"gas": 237995,
"calldata": "0x8f01f039...",
"router": "0x365193e7e200CC2Ce82eb67DB0Fed117F8C7c660",
"spender": "0x365193e7e200CC2Ce82eb67DB0Fed117F8C7c660"
}{
"code": "VALIDATION_ERROR",
"message": "Invalid request data",
"details": "<array>"
}{
"code": "UNAUTHORIZED",
"message": "Invalid API key."
}{
"code": "QUOTE_ERROR",
"message": "No quote available",
"details": "<unknown>"
}{
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests, please try again later."
}{
"code": "UPSTREAM_ERROR",
"message": "Upstream error: HTTP 500 Internal Server Error"
}Quote
Get Swap Quote
Returns the best swap quote for a pair of tokens and an input amount from the nexroute routing engine.
POST
/
quote
Get Swap Quote
curl --request POST \
--url https://api.nexroute.io/v1/quote \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"tokenIn": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
"tokenOut": "0x55d398326f99059fF775485246999027B3197955",
"amountIn": "1000000000000000000"
}
'import requests
url = "https://api.nexroute.io/v1/quote"
payload = {
"tokenIn": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
"tokenOut": "0x55d398326f99059fF775485246999027B3197955",
"amountIn": "1000000000000000000"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tokenIn: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
tokenOut: '0x55d398326f99059fF775485246999027B3197955',
amountIn: '1000000000000000000'
})
};
fetch('https://api.nexroute.io/v1/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nexroute.io/v1/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'tokenIn' => '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
'tokenOut' => '0x55d398326f99059fF775485246999027B3197955',
'amountIn' => '1000000000000000000'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nexroute.io/v1/quote"
payload := strings.NewReader("{\n \"tokenIn\": \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\",\n \"tokenOut\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amountIn\": \"1000000000000000000\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nexroute.io/v1/quote")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"tokenIn\": \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\",\n \"tokenOut\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amountIn\": \"1000000000000000000\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nexroute.io/v1/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tokenIn\": \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\",\n \"tokenOut\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amountIn\": \"1000000000000000000\"\n}"
response = http.request(request)
puts response.read_body{
"amountOut": "8643194859422640072",
"gas": 237995,
"calldata": "0x8f01f039...",
"router": "0x365193e7e200CC2Ce82eb67DB0Fed117F8C7c660",
"spender": "0x365193e7e200CC2Ce82eb67DB0Fed117F8C7c660"
}{
"code": "VALIDATION_ERROR",
"message": "Invalid request data",
"details": "<array>"
}{
"code": "UNAUTHORIZED",
"message": "Invalid API key."
}{
"code": "QUOTE_ERROR",
"message": "No quote available",
"details": "<unknown>"
}{
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests, please try again later."
}{
"code": "UPSTREAM_ERROR",
"message": "Upstream error: HTTP 500 Internal Server Error"
}Authorizations
API key for authentication
Body
application/json
Input token contract address (0x-prefixed, 40 hex characters)
Pattern:
^0x[a-fA-F0-9]{40}$Example:
"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"
Output token contract address (0x-prefixed, 40 hex characters)
Pattern:
^0x[a-fA-F0-9]{40}$Example:
"0x55d398326f99059fF775485246999027B3197955"
Input amount in wei (uint256 as decimal string, must be > 0)
Pattern:
^[1-9]\d*$Example:
"1000000000000000000"
Response
Successful quote response
Output amount in wei (uint256 as decimal string)
Example:
"8643194859422640072"
Estimated gas cost
Example:
237995
Calldata for the swap transaction
Example:
"0x8f01f039..."
Router contract address to call
Example:
"0x365193e7e200CC2Ce82eb67DB0Fed117F8C7c660"
Spender address for token approval
Example:
"0x365193e7e200CC2Ce82eb67DB0Fed117F8C7c660"
⌘I