
Complete DEX aggregation in one unified API package.
One API endpoint. One API key. Simple integration.
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:
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.
POST/GET https://yourproductiondomain.com/api/dexReplace with your actual production domain after deployment
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)
Ethereum DEX aggregation via 1inch - 300+ liquidity sources across ETH, BSC, Polygon, Arbitrum, Optimism
Solana DEX aggregation via Jupiter - 18+ DEXs including Orca, Raydium, Serum, Phoenix, Whirlpool
Get swap quotes via 1inch with automatic caching (10s TTL)
Execute token swaps via 1inch aggregator
Multi-wallet operations: connect, balance, transactions (MetaMask, Phantom, WalletConnect)
Solana Phantom wallet: connect, sign transactions, transaction history
Get token list with contract addresses, symbols, decimals
Historical price data for tokens with customizable time periods
AI assistance powered by Claude (requires ANTHROPIC_API_KEY)
NFT portfolio data via Moralis across multiple chains
Wallet balance and portfolio analytics via Moralis
Token metadata via Moralis with 5-minute cache
AI-powered DeFi insights (coming soon)
Copy and paste these examples to integrate all Locust Protocol features. All requests require the X-API-Key header (case-sensitive).
// 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// 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// 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());// 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());// 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// 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// 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// 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// 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 insightsAll 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!');Include your API key in every request header (case-sensitive):
X-API-Key: locust_your_api_key_hereImportant Notes: