Query Insights
Execute insight queries and retrieve results without creating a saved insight. This endpoint is useful for exploratory analysis, building custom dashboards, or programmatically analyzing your PostHog data.Endpoint
Path Parameters
The ID of the project to query
Query Parameters
How to handle result calculation:
force_cache- Return cached data only (fastest, may return cache miss)blocking- Calculate synchronously if cache is staleasync- Kick off background calculation if needed, return immediatelylazy_async- Background calculation for somewhat stale cacheforce_blocking- Always calculate synchronouslyforce_async- Always calculate in background
force_cacheOptional client-provided query ID for tracking and cancellation
Request Body
The request body should contain a query object matching one of the supported query types.Trends Query
Set to
TrendsQuery for trends analysisArray of event or action nodes to analyze
Date range for the analysis (e.g.,
{"date_from": "-7d"})Time interval:
hour, day, week, monthBreak down results by properties
Filter events by properties
Funnels Query
Set to
FunnelsQuery for conversion funnel analysisOrdered array of funnel steps (events or actions)
Time window for conversion (e.g., 7)
Unit for funnel window:
hour, day, week, monthHogQL Query
Set to
HogQLQuery for SQL queriesHogQL (SQL-like) query string
Response Fields
Query results (format depends on query type)
Whether there are more results available (for paginated queries)
Column definitions (for table results)
Data types for each column
The HogQL query that was executed (for debugging)
ISO 8601 timestamp of when results were calculated
Whether results came from cache
Timezone used for date calculations
Performance timing information
Examples
Trends Query
Query pageview trends over the last 7 days:Funnel Query
Analyze conversion through a signup funnel:HogQL Query
Run a SQL query using HogQL:Query with Breakdown
Analyze events broken down by a property:Response Examples
Trends Query Response
Funnel Query Response
HogQL Query Response
Error Responses
Invalid query structure
Invalid or missing API key
Insufficient permissions to query data
Rate limit exceeded
Query execution error
Notes
- Queries are executed against your ClickHouse analytics database
- Results are cached for performance; use
refreshparameter to control caching behavior - Use
force_cachefor fastest responses (may return cache miss if no cached results) - Use
blockingto ensure fresh results while maintaining synchronous response - Use
asyncfor expensive queries to avoid timeouts - Query execution is subject to rate limits
- HogQL queries must be read-only (SELECT statements only)
- Results are automatically formatted based on query type
- Aggregate queries (count, sum, etc.) return numeric results
- Time-series queries return arrays of data points