Skip to main content

Trading API

The Uniswap Trading API provides quote generation and transaction building for token swaps across 25+ chains. This API handles route optimization, gas estimation, and transaction encoding - you handle balance checks, transaction signing, and broadcasting.

Quick Start

Authentication

All requests require an API key:

curl -X POST https://trade.api.uniswap.org/v1/quote \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"tokenIn":"0x...","tokenOut":"0x...","amount":"1000000",...}'

Basic Quote Request

const response = await fetch('https://trade.api.uniswap.org/v1/quote', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
tokenIn: '0x0000000000000000000000000000000000000000', // ETH
tokenOut: '0xdAC17F958D2ee523a2206206994597C13D831ec7', // USDT
tokenInChainId: 1,
tokenOutChainId: 1,
type: 'EXACT_INPUT',
amount: '1000000000000000000', // 1 ETH in wei
swapper: '0x...', // User's wallet address
slippageTolerance: 0.5 // 0.5%
})
});

const quote = await response.json();

Architecture

Client-Side Responsibilities

The Trading API is a quote and transaction building service. Your application handles:

  1. Balance Checks: Verify token balances before requesting quotes
  2. Allowance Management: Check and request token approvals (ERC-20 approve or Permit2)
  3. Nonce Management: Track transaction nonces for the user's wallet
  4. Gas Estimation: Verify gas estimates before broadcasting
  5. Transaction Broadcasting: Sign and submit transactions via your RPC provider
  6. Transaction Monitoring: Track confirmations and handle reverts

Required Infrastructure

Your integration must include:

  • RPC Provider: Connection to blockchain nodes (Infura, Alchemy, or self-hosted)
  • Web3 Library: ethers.js, viem, or web3.js for transaction signing
  • Wallet Integration: WalletConnect, MetaMask, or similar for user signing

Data Flow

User Request
|
Your Application
|-- Check balances (via your RPC)
|-- Request quote (Trading API)
|-- Build transaction (Trading API response)
|-- Check allowances (via your RPC)
|-- Get user signature (Wallet)
|-- Manage nonce (your tracking)
+-- Broadcast transaction (via your RPC)
|
Blockchain

Available Endpoints

EndpointDescription
POST /quoteGenerate a quote for a token swap
POST /swapConvert a quote into an unsigned transaction
POST /check_approvalCheck if token approval is required
POST /swap_5792Generate batch transactions for EIP-5792
POST /swap_7702Generate transaction with EIP-7702 delegation
Cross-Chain PlansMulti-step cross-chain swap endpoints

Routing Types

The API returns different quote types based on the optimal routing strategy:

ValueTypeDescription
0CLASSICStandard AMM swap through Uniswap pools
1DUTCH_LIMITDutch auction order (UniswapX)
2DUTCH_V2Dutch auction V2
3LIMIT_ORDERLimit order
4WRAPETH to WETH wrap
5UNWRAPWETH to ETH unwrap
6BRIDGECross-chain bridge
7PRIORITYMEV-protected priority order
8DUTCH_V3Dutch auction V3
9QUICKROUTEFast approximation quote
10CHAINEDMulti-step cross-chain swap

Getting Started

  1. Get an API Key: Contact the Uniswap team to request API access
  2. Set Up Infrastructure: Configure your RPC provider and wallet integration
  3. Implement the Flow: Follow the integration guide for step-by-step implementation
  4. Test on Testnet: Validate your integration before going live

Next Steps