Unique to Dune: Server-side result filtering is a powerful feature that sets Dune’s API apart. Filter millions of rows using SQL-like WHERE clauses without transferring unnecessary data or processing client-side.
Overview
Dune’s API supports sophisticated filtering on all/results endpoints, allowing you to refine query results server-side. Apply filters on rows and columns to dramatically reduce bandwidth and processing time.
Benefits:
- Reduce bandwidth: Only transfer the data you need
- Save processing time: Filter server-side before data transfer
- Simplify client code: No need for complex client-side filtering logic
- Lower costs: Minimize data transfer and API calls
Example Filtering Request
- Python SDK
- cURL
- Python
- Javascript
- Go
- PHP
- Java
Filtering Parameters
filters
- Type:
string - Description: Allows specifying criteria to filter rows in the result set. It functions similarly to a SQL
WHEREclause. If omitted, all results are returned.
- Use the format
<column_name> <operator> <value>for criteria, for example,block_time >= '2024-03-05 15:03'. - Combine criteria using parentheses and logical operators
AND/OR, e.g.,block_time >= '2024-03-05 15:03' AND (project = 'uniswap' OR project = 'balancer'). - The
INoperator is permitted, as intx_to IN (0x6a3e4b7e23661108aaec70266c468e6c679ae022, 0xdbf89389504e39f03fbb6bdd601aabb6bfbbed71). - The
NOToperator is not supported; usingNOT INorNOT LIKEwill produce an error. - For column names with special characters (e.g., spaces, emojis, dashes, dots), enclose them in double quotes:
"special, column" = 'ABC'. - Values must be strings or numbers. SQL expressions like
now() - interval '1' dayare not allowed. - Dates and times should be formatted as strings, e.g.,
block_time > '2023-01-03'.
columns
- Type:
string - Description: Specifies the column names to include in the result set. If omitted, all columns are returned.
- List column names without spaces, e.g., use
project,block_time,amount_usdinstead ofproject, block_time, amount_usd. - Specifying columns helps limit the results to essential data, reducing the data cost of the call.
Common Filtering Patterns
Filter by Time Range
Filter by Value Thresholds
Filter by Category
Complex Conditions
Filter with Column Selection
Real-World Examples
Example 1: Whale Transactions
Example 2: Protocol-Specific Analytics
Example 3: Token-Specific Monitoring
Example 4: Multi-Chain Analysis
Filtering Best Practices
Always filter time ranges
Always filter time ranges
Reduce the amount of data scanned by filtering by
block_time:Combine filters with column selection
Combine filters with column selection
Minimize bandwidth by only requesting needed columns:
Use IN for multiple values
Use IN for multiple values
More efficient than multiple OR conditions:
Be specific with data types
Be specific with data types
Use proper quoting for strings, no quotes for numbers:
Handle special column names
Handle special column names
Use double quotes for columns with special characters:
Limitations
Filtered Response
Example filtered response
Example filtered response