Pagination, Filtering, and Sorting
Master efficient data retrieval with pagination, filtering, and sorting. Learn how to optimize queries and reduce API calls using query parameters.
Smart Money API uses cursor-based pagination for efficient data retrieval. Specify page number and limit to control result sets.
| Parameter |
Type |
Default |
Max |
| page |
integer |
1 |
N/A |
| limit |
integer |
50 |
500 |
Pagination Example
# Get first 100 results
curl "https://api.smartmoneyapi.com/v1/whales/events?page=1&limit=100"
# Get second page
curl "https://api.smartmoneyapi.com/v1/whales/events?page=2&limit=100"
Response Pagination Info
{
"success": true,
"data": {...},
"pagination": {
"page": 1,
"limit": 50,
"total": 420,
"total_pages": 9,
"has_next": true,
"has_prev": false
}
}
Filtering
Filter results by symbol, exchange, direction, and other criteria. Filters are combined with AND logic.
| Filter |
Values |
Example |
| symbol |
Trading pair |
BTCUSDT, ETHUSDT |
| exchange |
bybit, binance, hyperliquid |
bybit |
| direction |
long, short |
long |
| min_position_size |
Number |
10.5 |
| min_pnl_percent |
Number |
2.0 |
Filtering Example
# Filter by symbol and direction
curl "https://api.smartmoneyapi.com/v1/whales/events?symbol=BTCUSDT&direction=long"
# Filter by exchange and minimum position size
curl "https://api.smartmoneyapi.com/v1/whales/events?exchange=bybit&min_position_size=15"
Sorting
Sort results by position size, P&L, or other fields. Specify field and direction (asc/desc).
# Sort by position size descending (largest first)
curl "https://api.smartmoneyapi.com/v1/whales/events?sort=position_size&order=desc"
# Sort by P&L ascending
curl "https://api.smartmoneyapi.com/v1/whales/events?sort=pnl_percent&order=asc"
Complete Examples
Python: Iterate Through All Pages
import requests
def get_all_whale_positions(api_key, symbol=None):
"""Fetch all whale positions with pagination"""
all_positions = []
page = 1
while True:
params = {
"page": page,
"limit": 100, # Max batch size
"sort": "position_size",
"order": "desc"
}
if symbol:
params["symbol"] = symbol
response = requests.get(
"https://api.smartmoneyapi.com/v1/whales/events",
headers={"Authorization": f"Bearer {api_key}"},
params=params
)
data = response.json()
all_positions.extend(data["data"]["positions"])
# Check if there are more pages
if not data["pagination"]["has_next"]:
break
page += 1
return all_positions
# Usage
positions = get_all_whale_positions("sk_live_abc123xyz789", symbol="BTCUSDT")
print(f"Found {len(positions)} whale positions")
Best Practices
1. Use maximum limit (100-500): Fewer API calls to retrieve same amount of data. Batch results efficiently.
2. Filter server-side: Use query parameters to filter at source, not in your application code. Reduces data transfer.
3. Sort on the server: Request sorted results from the API. Sorting at scale is efficient on the server.
4. Cache and paginate: Cache results locally and paginate through cached data to minimize API calls.
5. Stop early if possible: Don't always fetch all pages. Stop when you have enough data for your use case.
Learn More
Explore the complete API reference for all filtering and sorting options.