Query Builder
Generate and preview SQL queries for incentive data sources
The query builder tools generate SQL queries that define what user activity an incentive tracks and how it's measured.
generate_incentive_query
Generate a SQL query for any incentive source. Set the source parameter to select the data source, then provide source-specific parameters.
Requires: authentication, active project
Common Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
source | "swap" | "bonding_curve" | "hold" | "custom_event" | "idl_instruction" | Yes | Data source for the query |
confirmed | boolean | No | Set to true to confirm (custom_event, idl_instruction). Omit to preview. |
Token Swap Parameters
| Parameter | Type | Description |
|---|---|---|
tokenMint | string | SPL token mint address (required) |
direction | "buy" | "sell" | "both" | Trade direction (default: "buy") |
measure | "volume" | "count" | What to measure |
minUsdAmount | number | Minimum USD value per swap |
protocol | string | DEX protocol filter (e.g. Jupiter, Raydium) |
Bonding Curve Parameters
| Parameter | Type | Description |
|---|---|---|
tokenMint | string | SPL token mint address (required) |
launchpad | "raydium_launchlab" | "metaplex_genesis" | Launchpad program (required) |
direction | "buy" | "sell" | "both" | Trade direction (default: "buy") |
measure | "volume" | "count" | What to measure |
poolState | string | Pool state address (required for raydium_launchlab) |
genesisAccount | string | Genesis account (required for metaplex_genesis) |
minAmountIn | number | Minimum purchase size in raw amount |
Token Hold Parameters
| Parameter | Type | Description |
|---|---|---|
tokenMint | string | SPL token mint address (required) |
measure | "balance" | "duration" | "count" | What to measure |
minBalance | number | Minimum token balance (required) |
Custom Event Parameters
| Parameter | Type | Description |
|---|---|---|
customEventId | string | Custom event ID (required) |
valueExpression | string | Value expression, e.g. "SUM(amount)", "COUNT(*)" |
filters | string[] | WHERE conditions using field names |
groupByPubkey | boolean | Group by pubkey (default: true) |
orderBy | "DESC" | "ASC" | Sort order |
limit | number | Max rows |
rawQuery | string | Raw SQL with {{startDate}}/{{endDate}} params |
IDL Instruction Parameters
| Parameter | Type | Description |
|---|---|---|
instructionId | string | Instruction ID (required) |
valueExpression | string | Value expression |
filters | string[] | WHERE conditions |
groupByFeePayer | boolean | Group by fee payer (default: true) |
orderBy | "DESC" | "ASC" | Sort order |
limit | number | Max rows |
rawQuery | string | Raw SQL with {{startDate}}/{{endDate}} params |
preview_incentive_query
Execute a SQL query against real indexed data and preview the results before creating an incentive. The query runs asynchronously with up to 60 seconds timeout. By default, previews the last 3 complete days of data.
Requires: authentication, active project
| Parameter | Type | Required | Description |
|---|---|---|---|
sqlQuery | string | Yes | The SQL query to preview |
startDate | string | No | ISO 8601 start date (default: 3 days ago) |
endDate | string | No | ISO 8601 end date (default: today at midnight) |
Always preview your query before creating an incentive. This validates that the query produces the expected shape and data using real indexed data.
The query may be queued before it starts executing. The assistant will let you know it's waiting for results — this typically takes a few seconds but can take up to 60 seconds for complex queries.