API Reference
Active Orders API
Query and stream fillable DCA orders in real-time
Active Orders API
The Active Orders API provides both HTTP and WebSocket interfaces for accessing fillable DCA orders, enabling bots and integrations to monitor and execute orders as they become available.
HTTP Endpoint
Get Active Orders
GET https://api.dca.fun/active-orders?chainId={chainId}Returns a list of all DCA orders that are currently fillable on a specific blockchain network.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | integer | Yes | Blockchain network ID (1, 137, 8453, 42161, 10, 84532) |
Response Format
{
"data": [
{
"id": 123,
"creator": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"tokenIn": {
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"feed": "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6",
"decimals": 6,
"symbol": "USDC",
"name": "USD Coin"
},
"tokenOut": {
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"feed": "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419",
"decimals": 18,
"symbol": "WETH",
"name": "Wrapped Ether"
},
"spendAmount": 100000000,
"slippage": 100,
"freqInterval": 86400,
"lastRun": 1704067200,
"nextRun": 1704153600
}
],
"count": 1
}Code Examples
// Get all fillable orders on Base
const response = await fetch(
'https://api.dca.fun/active-orders?chainId=8453'
);
const { data: orders, count } = await response.json();
console.log(`Found ${count} fillable orders`);
// Process each order
for (const order of orders) {
console.log(`Order ${order.id}: ${order.tokenIn.symbol} → ${order.tokenOut.symbol}`);
console.log(`Spend amount: ${order.spendAmount}`);
console.log(`Slippage: ${order.slippage / 100}%`);
}import requests
# Get all fillable orders on Base
response = requests.get(
'https://api.dca.fun/active-orders',
params={'chainId': 8453}
)
data = response.json()
print(f"Found {data['count']} fillable orders")
# Process each order
for order in data['data']:
print(f"Order {order['id']}: {order['tokenIn']['symbol']} → {order['tokenOut']['symbol']}")
print(f"Spend amount: {order['spendAmount']}")
print(f"Slippage: {order['slippage'] / 100}%")# Get all fillable orders on Base
curl "https://api.dca.fun/active-orders?chainId=8453"WebSocket API
WebSocket Stream
wss://api.dca.fun/ordersStreams all fillable DCA orders with real-time updates, perfect for MEV bots and order fillers.
WebSocket Connection
Basic Connection
const ws = new WebSocket("wss://api.dca.fun/orders");
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
console.log("Fillable orders:", message.data);
};
// Send commands
ws.send("refresh"); // Manual refresh
ws.send("ping"); // Health checkMessage Format
{
"type": "initial|update|refresh|response|error",
"timestamp": 1704067200000,
"success": true,
"data": [...],
"rowCount": 42
}Order Structure
interface TransactableOrder {
id: string; // Order ID
creator: {
creatorAddress: string; // Creator's address
};
tokenIn: {
tokenAddress: string; // Token to sell
feed: string; // Chainlink feed ID
decimals: number;
symbol: string;
name: string;
};
tokenOut: {
tokenAddress: string; // Token to buy
feed: string; // Chainlink feed ID
decimals: number;
symbol: string;
name: string;
};
spendAmount: string; // Amount per execution
vault: string; // Vault address
slippage: string; // Max slippage (basis points)
freqInterval: string; // Seconds between executions
nextRun: string; // Unix timestamp of next execution
scalingFactor: string; // Scaling interval
}Order Filtering
Orders must meet ALL criteria:
- Not cancelled
- Current time >=
nextRun - Has remaining repeats
- Sorted by slippage (highest first)
Integration Examples
Basic Monitor
class OrderMonitor {
constructor(wsUrl) {
this.orders = new Map();
this.connect(wsUrl);
}
connect(wsUrl) {
this.ws = new WebSocket(wsUrl);
this.ws.onmessage = (event) => {
const { success, data } = JSON.parse(event.data);
if (success) this.processOrders(data);
};
this.ws.onclose = () => {
setTimeout(() => this.connect(wsUrl), 5000);
};
}
processOrders(orders) {
const current = new Set();
for (const order of orders) {
current.add(order.id);
if (!this.orders.has(order.id)) {
console.log(`New order: ${order.id}`);
this.analyzeOrder(order);
}
this.orders.set(order.id, order);
}
// Remove filled orders
for (const [id] of this.orders) {
if (!current.has(id)) this.orders.delete(id);
}
}
}Best Practices
Connection Management
- Implement automatic reconnection with backoff
- Monitor connection health
- Handle message types appropriately
Performance
- Process orders in parallel
- Cache preview results (10-30s max)
- Prioritize high-profit orders
- Limit concurrent executions
Performance
- Update frequency: 2 seconds
- Connection limits: Per IP (contact for details)
- Latency: Typically < 100ms
Related Endpoints
- Quote API - Get execution quotes
- Smart Contract API - On-chain execution
- Complete API Reference - Full documentation