Locust Protocol

Locust Protocol Documentation

Complete DEX aggregation in one unified API package.

One API endpoint. One API key. Simple integration.

Your Locust Protocol API Key

When you sign up, you receive a unique locust_ prefixed API key. This key connects your application directly to Locust Protocol's unified DEX aggregation API.

Your API key provides access to:

  • 5 aggregated external APIs in one unified endpoint
  • 300+ liquidity sources on Ethereum via 1inch (requires ONEINCH_API_KEY)
  • 18+ DEXs on Solana via Jupiter (public API, no key needed)
  • Client-side wallet integration support (MetaMask, Phantom, WalletConnect, Coinbase)
  • NFT data and wallet analytics via Moralis (requires MORALIS_API_KEY)
  • AI-powered DeFi assistance via Claude (requires ANTHROPIC_API_KEY)
  • Morphic AI insights via OpenAI (requires OPENAI_API_KEY)
  • Real-time price data and historical charts

All API requests to /api/dex are authenticated using your Locust Protocol API key in the X-API-Key request header (case-sensitive).

IMPORTANT: Secure Your API Key

Get your personal Locust Protocol API key from the Dashboard. Keep it private and never share it publicly or commit it to version control.

Locust Protocol Integration
One endpoint for complete DEX functionality

Locust Protocol API Endpoint

POST/GET https://yourproductiondomain.com/api/dex

Replace with your actual production domain after deployment

Locust Protocol Actions

Access all DEX functionality through the action parameter.

Locust Protocol aggregates data from: 1inch (300+ DEXs), Jupiter (18 DEXs), Moralis (multi-chain data), Anthropic Claude (AI), and OpenAI (Morphic AI)

ETH (GET)

Ethereum DEX aggregation via 1inch - 300+ liquidity sources across ETH, BSC, Polygon, Arbitrum, Optimism

SOL (GET)

Solana DEX aggregation via Jupiter - 18+ DEXs including Orca, Raydium, Serum, Phoenix, Whirlpool

quote (GET)

Get swap quotes via 1inch with automatic caching (10s TTL)

swap (POST)

Execute token swaps via 1inch aggregator

wallet (GET)

Multi-wallet operations: connect, balance, transactions (MetaMask, Phantom, WalletConnect)

phantom (GET)

Solana Phantom wallet: connect, sign transactions, transaction history

tokens (GET)

Get token list with contract addresses, symbols, decimals

price-history (GET)

Historical price data for tokens with customizable time periods

claude (GET)

AI assistance powered by Claude (requires ANTHROPIC_API_KEY)

moralis-nft (GET)

NFT portfolio data via Moralis across multiple chains

moralis-wallet (GET)

Wallet balance and portfolio analytics via Moralis

moralis-token (GET)

Token metadata via Moralis with 5-minute cache

morphic (POST)

AI-powered DeFi insights (coming soon)

Complete API Integration Examples

Copy and paste these examples to integrate all Locust Protocol features. All requests require the X-API-Key header (case-sensitive).

1. Ethereum DEX Aggregation (ETH)

// Get Ethereum swap quote (1 ETH to USDC)
const ethQuote = await fetch(
  'https://yourproductiondomain.com/api/dex?action=ETH&fromToken=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&toToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&amount=1000000000000000000&chainId=1',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

console.log(ethQuote); // 300+ liquidity sources via 1inch

2. Solana DEX Aggregation (SOL)

// Get Solana swap quote (1 SOL to USDC)
const solQuote = await fetch(
  'https://yourproductiondomain.com/api/dex?action=SOL&inputMint=So11111111111111111111111111111111111111112&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=1000000000',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

console.log(solQuote); // Aggregates 18+ DEXs via Jupiter

3. Wallet Management (MetaMask, Phantom, WalletConnect)

// Connect multi-chain wallet (includes MetaMask, Phantom, WalletConnect)
const walletConnect = await fetch(
  'https://yourproductiondomain.com/api/dex?action=wallet&operation=connect',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

// Get wallet balance
const balance = await fetch(
  'https://yourproductiondomain.com/api/dex?action=wallet&operation=balance&address=0x...&chain=ethereum',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

// Get transaction history
const transactions = await fetch(
  'https://yourproductiondomain.com/api/dex?action=wallet&operation=transactions&address=0x...&chain=ethereum',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

4. Phantom Wallet Integration

// Connect Phantom wallet
const phantomConnect = await fetch(
  'https://yourproductiondomain.com/api/dex?action=phantom&operation=connect',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

// Sign transaction with Phantom
const phantomSign = await fetch(
  'https://yourproductiondomain.com/api/dex?action=phantom&operation=sign&address=YourSolanaAddress...',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

// Get Phantom transaction history
const phantomTxs = await fetch(
  'https://yourproductiondomain.com/api/dex?action=phantom&operation=transaction&address=YourSolanaAddress...',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

5. Execute Token Swap (POST)

// Execute swap transaction
const swap = await fetch('https://yourproductiondomain.com/api/dex', {
  method: 'POST',
  headers: {
    'X-API-Key': 'locust_your_api_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    action: 'swap',
    fromToken: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
    toToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
    amount: '1000000000000000000',
    userAddress: '0x...',
    slippage: 1,
    chain: '1'
  })
}).then(res => res.json());

console.log(swap); // Transaction data for execution

6. Get Token Lists

// Get aggregated token list
const tokens = await fetch(
  'https://yourproductiondomain.com/api/dex?action=tokens',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

console.log(tokens); // Returns token addresses, symbols, decimals

7. Get Price History

// Get historical price data
const priceHistory = await fetch(
  'https://yourproductiondomain.com/api/dex?action=price-history&token=ETH&period=24h',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

console.log(priceHistory); // Array of price points with timestamps

8. AI Assistant (Claude)

// Get AI-powered DeFi assistance
const aiResponse = await fetch(
  'https://yourproductiondomain.com/api/dex?action=claude&prompt=Explain how token swaps work',
  {
    headers: { 'X-API-Key': 'locust_your_api_key_here' }
  }
).then(res => res.json());

console.log(aiResponse.response); // AI-generated explanation

9. Morphic AI Insights (POST)

// Get AI-powered DeFi insights
const morphic = await fetch('https://yourproductiondomain.com/api/dex', {
  method: 'POST',
  headers: {
    'X-API-Key': 'locust_your_api_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    action: 'morphic',
    query: 'What are the best liquidity pools for ETH/USDC?'
  })
}).then(res => res.json());

console.log(morphic.response); // AI-generated DeFi insights

Complete Integration Example

All actions integrated in a single implementation:

// Locust Protocol - Complete API Integration
const API_BASE = 'https://yourproductiondomain.com/api/dex';
const API_KEY = 'locust_your_api_key_here';

// Helper function for API calls
async function locustAPI(action, params = {}, method = 'GET') {
  const url = method === 'GET' 
    ? `${API_BASE}?action=${action}&${new URLSearchParams(params)}`
    : API_BASE;
    
  const options = {
    method,
    headers: {
      'X-API-Key': API_KEY,
      'Content-Type': 'application/json'
    }
  };
  
  if (method === 'POST') {
    options.body = JSON.stringify({ action, ...params });
  }
  
  return fetch(url, options).then(res => res.json());
}

// Usage examples:
// 1. Ethereum swap quote via 1inch
const ethQuote = await locustAPI('ETH', {
  fromToken: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
  toToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  amount: '1000000000000000000',
  chainId: '1'
});

// 2. Solana swap quote via Jupiter
const solQuote = await locustAPI('SOL', {
  inputMint: 'So11111111111111111111111111111111111111112',
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  amount: '1000000000'
});

// 3. Wallet connection (supports MetaMask, Phantom, WalletConnect, Coinbase)
const wallet = await locustAPI('wallet', { operation: 'connect' });
const balance = await locustAPI('wallet', { 
  operation: 'balance', 
  address: '0x...', 
  chain: 'ethereum' 
});

// 4. Phantom wallet operations
const phantom = await locustAPI('phantom', { operation: 'connect' });

// 5. Execute swap via 1inch
const swap = await locustAPI('swap', {
  fromToken: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
  toToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  amount: '1000000000000000000',
  userAddress: '0x...',
  slippage: 1,
  chain: '1'
}, 'POST');

// 6. Token list
const tokens = await locustAPI('tokens');

// 7. Price history
const prices = await locustAPI('price-history', { 
  token: 'ETH', 
  period: '24h' 
});

// 8. Claude AI Assistant
const ai = await locustAPI('claude', { 
  prompt: 'Explain how DEX aggregation works' 
});

// 9. Moralis NFT data
const nfts = await locustAPI('moralis-nft', {
  address: '0x...',
  chain: 'eth'
});

// 10. Moralis wallet analytics
const walletData = await locustAPI('moralis-wallet', {
  address: '0x...',
  chain: 'eth'
});

// 11. Moralis token metadata
const tokenMeta = await locustAPI('moralis-token', {
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  chain: 'eth'
});

console.log('Locust Protocol integration complete!');
Get Started
Three simple steps to DEX integration
  1. Create your free account
  2. Copy your API key from the Dashboard
  3. Add the API endpoint to your code
Authentication

Include your API key in every request header (case-sensitive):

X-API-Key: locust_your_api_key_here

Important Notes:

  • Header name is X-API-Key (case-sensitive)
  • API keys start with locust_ prefix
  • Get your key from the Dashboard
  • 7-day free trial for all new users
  • After trial: $49/month for unlimited access

Locust Protocol - $49/month

  • Unlimited API requests
  • Multi-chain DEX aggregation (ETH + SOL)
  • Complete wallet management (MetaMask, Phantom, WalletConnect)
  • AI assistant access
  • Real-time price data
  • Priority support
Need Help?

Questions about integration?