Skip to main content
Downloading historical trade data is essential for backtesting strategies, building analytics dashboards, and conducting market research. Mobula’s /api/2/trades/filters endpoint makes it easy to batch download trades across any blockchain with efficient cursor-based pagination. This cookbook walks you through downloading large volumes of trade data efficiently.

Quick Start

Here’s the simplest way to download trades for a 1-hour window:

Understanding the Endpoint

Key Parameters

Constraints

  • Maximum timeframe: 1 hour per request
  • Maximum results: 5000 per request
  • Use cursor pagination to fetch more results within a timeframe

Batch Download Strategy

Step 1: Break Down Your Timeframe

Since each request is limited to 1 hour, break your target period into 1-hour chunks:

Step 2: Paginate Within Each Chunk

Each 1-hour chunk may contain more than 5000 trades. Use cursor pagination to fetch all trades:

Step 3: Complete Download Pipeline

Combine time chunking and pagination for a complete solution:

Python Example


Working with the Response Data

Trade Object Structure

Each trade includes comprehensive data:

Analytics Examples

Calculate total volume:
Group by token:
Find largest trades:

Best Practices

Use ascending sort order (sortOrder=asc) for batch downloads. This ensures consistent cursor-based pagination and chronological data ordering.
Respect rate limits: Add small delays between requests (100-200ms) to avoid hitting rate limits, especially when downloading large datasets.
Base/Quote token logic: When you provide a tokenAddress filter, that token becomes the “base” token and the type field (buy/sell) is relative to it. Without a filter, token0 from the pool is used as base.

Common Use Cases

1. Backtesting Trading Strategies

Download historical trades to simulate how your strategy would have performed.

2. Market Analysis

Analyze trading patterns, volume trends, and market maker activity.

3. Building Leaderboards

Track top traders by volume or profit across specific tokens or chains.

4. DEX Analytics Dashboards

Build real-time dashboards showing trading activity across multiple chains.

5. Whale Tracking

Identify large trades and track wallet activity for market intelligence.

Get Started

Ready to download trade data?
  1. Get your free API key
  2. Read the API reference
  3. Join our Discord for support