Skip to main content
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
Available on these endpoints: Filtering can be effectively used in conjunction with pagination and sorting to further enhance query efficiency and relevance. See an example of filtering in action with this Dune farcaster frame.

Example Filtering Request

Filtering Parameters

filters

  • Type: string
  • Description: Allows specifying criteria to filter rows in the result set. It functions similarly to a SQL WHERE clause. 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 IN operator is permitted, as in tx_to IN (0x6a3e4b7e23661108aaec70266c468e6c679ae022, 0xdbf89389504e39f03fbb6bdd601aabb6bfbbed71).
  • The NOT operator is not supported; using NOT IN or NOT LIKE will 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' day are 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_usd instead of project, 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

Performance tip: Combine filtering with column selection to minimize data transfer. For example, instead of fetching all 50 columns for millions of rows, fetch only the 5 columns you need for 1000 filtered rows.

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

Reduce the amount of data scanned by filtering by block_time:
Minimize bandwidth by only requesting needed columns:
More efficient than multiple OR conditions:
Use proper quoting for strings, no quotes for numbers:
Use double quotes for columns with special characters:

Limitations

  • No SQL expressions: Filters must use literal values. Expressions like now() - interval '1' day are not supported. Calculate values client-side instead.
  • No NOT operator: NOT IN and NOT LIKE are not supported. Use positive conditions instead.
  • No subqueries: Filters cannot contain subqueries. Use parameterized queries for complex logic.
  • String and number values only: Filters only support string and numeric literals.

Filtered Response