Native Documentation
  • introduction
    • What is Native
    • About Native V2
    • Benefits for Key Players
  • SOLUTION
    • Native Credit Pool
    • Native Swap Engine
  • CONCEPTS
    • Orderbook
    • Firm Quote Orders
    • Auto Sign Orders
    • Swap Fees
    • Slippage
    • Base and Listed Assets
    • Single-Sided Liquidity Pools
    • Total Available Liquidity
    • Liquidity Pairing
    • Liquidity Bootstrapping
    • Health Ratio
    • Earning Fees and Incentives
    • Credit-Based Swap
      • Collateral Factor
      • PMM Credit
      • Settlement and Liquidation
    • Market-Responsive Pricing
    • Risks
  • USER GUIDE
    • Add Liquidity
    • Pair Liquidity
    • Claim Rewards
    • Swap with Native
  • Build with Native
    • Swap Aggregators
      • Guide
      • FirmQuote Swap APIs
        • GET Orderbook
        • GET Indicative quote
        • GET Firm quote
    • Asset Issuers
      • For Pegged Assets
      • For General Assets
  • Resources
    • Addresses
    • Audits
    • Github
    • System Status
    • Business Source License
    • Media Kit
Powered by GitBook
On this page
  • Typescript
  • Python
  1. Build with Native
  2. Swap Aggregators
  3. FirmQuote Swap APIs
  4. Old docs
  5. GET /indicative-quote

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 9 months ago