Example: Get Quote for ETH to USDT
Getting a Quote for 1 ETH to USDT on Ethereum
Typescript
import axios from 'axios';
const apiKey = '' // Contact Native to get your API key;
const baseUrl = 'https://newapi.native.org/v1/';
const walletAddress = '' // Your wallet address;
// Swap input
const chain = 'ethereum'; // 1, 56
const tokenIn = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'; // ETH
const tokenOut = '0xdAC17F958D2ee523a2206206994597C13D831ec7'; // USDT
const amount = 1; // in ether, not in wei
async function callIndicativeQuote() {
const endpoint = 'indicative-quote?';
const headers: any = {
apiKey: apiKey,
};
const response = await axios
.get(
`${baseUrl}${endpoint}chain=${chain}&token_in=${tokenIn}&token_out=${tokenOut}&amount=${amount}&from_address=${walletAddress}`,
{
headers,
}
)
console.log('Quote result', response.data)
}
Python
import requests
import urllib.parse
apiKey = '' // Contact Native to get your API key;
baseUrl = "https://newapi.native.org/v1/"
walletAddress = '' // Your wallet address;
# Swap input
chainId = 'ethereum'; # 1, 56
tokenIn = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'; # ETH
tokenOut = '0xdAC17F958D2ee523a2206206994597C13D831ec7'; # USDT
amount = 1; # in ether, not in wei
# indicative quote
def call_indicative_quote():
endpoint = "indicative-quote?"
params = {
"chain": chain,
"token_in": tokenIn,
"token_out": tokenOut,
"amount": amount,
"from_address": walletAddress,
}
response = requests.request(
"GET",
baseUrl + endpoint + urllib.parse.urlencode(params),
data="",
headers={
"apiKey": apiKey,
},
params=params,
timeout=3,
)
print("Get indicative quote")
print(response.status_code)
print(response.json())
Last updated