Getting Started
Welcome to the Lion Swap API documentation. Our API enables you to integrate cross-chain swaps into your application.
Installation
npm install @lionswap/sdk
# or
yarn add @lionswap/sdk
Authentication
All API requests require authentication using API keys. You can generate API keys from your dashboard.
const LionSwap = require('@lionswap/sdk');
const client = new LionSwap({
apiKey: 'your-api-key',
environment: 'mainnet' // or 'testnet'
});
API Reference
Endpoints
| Endpoint | Description |
|---|---|
| /v1/quote | Get quote for token swap |
| /v1/swap | Execute token swap |
| /v1/status | Check swap status |
SDK Integration
Our SDK provides a simple way to interact with the Lion Swap protocol.
// Initialize the SDK
const swap = await client.createSwap({
fromToken: 'ETH',
toToken: 'USDC',
amount: '1.0',
fromChain: 'ethereum',
toChain: 'polygon'
});
WebSocket API
Real-time updates for swap status and price feeds.
const ws = new LionSwap.WebSocket('wss://api.lionswap.com/ws');
ws.subscribe('PRICE_FEED', {
pairs: ['ETH/USDC', 'BTC/USDT']
});
Code Examples
Simple Swap Example
// Complete swap example
const swap = await client.createSwap({
fromToken: 'ETH',
toToken: 'USDC',
amount: '1.0',
fromChain: 'ethereum',
toChain: 'polygon'
});
// Wait for confirmation
const receipt = await swap.wait();
console.log('Swap completed:', receipt);