Documentation

Getting Started

What is the Swap API?

Get live quotes and execute swaps on Aerodrome (Base) and Velodrome (Optimism) without running your own nodes or building complex routing logic.

Free while in beta • No rate limits • Production ready

What You Can Build

🔄 Token Swap Interfaces

Build swap UIs with live quotes, slippage protection, and one-click execution.

Uses: /v1/tokens, /v1/quote, /v1/swap/build

📊 Portfolio Trackers

Real-time token prices for portfolio valuation and performance tracking.

Uses: /v1/prices, /v1/tokens

🤖 Trading Bots

Automated trading with live quotes, gas optimization, and transaction monitoring.

Uses: /v1/quote, /v1/gas-price, /v1/transaction

🔍 DeFi Analytics

Pool discovery, liquidity analysis, and market data for research platforms.

Uses: /v1/pools, /v1/prices, /v1/tokens

Why Use This API?

⚡ No Infrastructure

Skip running Base/Optimism nodes, indexing pools, or building routing algorithms. Just call our API.

🎯 Always Fresh

Live quotes that update every block. No stale prices or failed swaps due to outdated data.

🚀 Production Scale

Built on QuickNode infrastructure. Handles millions of requests with 99.95% uptime.

Explore the API

Each section below contains interactive examples you can run directly in your browser. Start with the endpoint that matches your use case:

🔑 Need API Access?

Get your API key from the QuickNode marketplace. Takes 30 seconds and includes free usage while in beta.

Get API Access

Quick Start Examples

Choose your language:

💱 Get Token Quote

Get a swap quote for AERO → USDC

// Get swap quote
const response = await fetch(
  'https://your-endpoint.../v1/quote?' + 
  new URLSearchParams({
    quotetarget: 'base',
    from_token: '0x940181a94A35A4569E4529A3CDfB74e38FD98631',
    to_token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
    amount: '1',
    slippage: '0.005'
  })
);

const quote = await response.json();
console.log('Quote:', quote.execution_price);
console.log('Slippage:', quote.slippage);

🔍 Search Tokens

Find tokens for your swap interface

// Search for tokens
const searchTokens = async (query) => {
  const response = await fetch(
    `https://your-endpoint.../v1/tokens/search?target=base&query=${query}&limit=10`
  );
  
  const data = await response.json();
  return data.tokens.map(token => ({
    symbol: token.symbol,
    address: token.address,
    name: token.name
  }));
};

// Usage
const tokens = await searchTokens('AERO');
console.log(tokens);

💰 Get Token Prices

Fetch real-time token prices

// Get token prices
const getPrices = async (symbols) => {
  const response = await fetch(
    `https://your-endpoint.../v1/prices?target=aero&symbols=${symbols.join(',')}&limit=50`
  );
  
  const data = await response.json();
  
  // Extract prices
  const prices = {};
  Object.entries(data.prices).forEach(([address, info]) => {
    prices[info.token.symbol] = info.price;
  });
  
  return prices;
};

// Usage
const prices = await getPrices(['AERO', 'USDC', 'WETH']);
console.log('AERO Price:', prices.AERO);

⚡ Build Swap Transaction

Create transaction for wallet signing

// Build swap transaction
const buildSwap = async (fromToken, toToken, amount, walletAddress) => {
  const response = await fetch(
    'https://your-endpoint.../v1/swap/build?target=base',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        from_token: fromToken,
        to_token: toToken,
        amount: amount,
        wallet_address: walletAddress,
        slippage: 0.005
      })
    }
  );
  
  const transaction = await response.json();
  return transaction;
};

// Usage
const tx = await buildSwap(
  '0x940181a94A35A4569E4529A3CDfB74e38FD98631', // AERO
  '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC
  1.0,
  '0xYourWalletAddress'
);