Grain logomark

Query API

Extract insights from your analytics data with SQL-like queries. Build custom dashboards, export data, and power your data workflows with a simple REST API.


POST /v1/api/query/count/{tenantId}

{
  "event": "page_viewed",
  "after": "2025-10-01",
  "before": "2025-10-22",
  "filterSet": [{
    "property": "page_path",
    "comparison": "equals",
    "value": "/pricing"
  }]
}

→ Returns: { "count": 4821 }

Key Capabilities

Everything you need to succeed

Fast Queries

Optimized queries powered by ClickHouse. Count endpoints are especially fast for aggregations and dashboards.

Flexible Queries

Query events with filters, count matching events, and list event names. Filter by any property with multiple comparison operators.

Advanced Filtering

Filter by user properties, event properties, date ranges, and more. Combine multiple conditions with AND/OR logic.

Secure & Reliable

API key authentication, rate limiting, and automatic retry logic. Enterprise-grade security with audit logs.

Pagination Support

Handle large datasets efficiently with cursor-based pagination. Fetch results in manageable chunks.

Date Range Filtering

Query events within specific time periods. Use after/before parameters for precise date filtering.

Built to Excel

Designed to outperform the competition


Easy

No Query Language Required

Simple REST API with JSON payloads. No SQL or complex query languages to learn. Start querying in minutes.


Powerful

Flexible Filtering

Filter by any event property with multiple comparison operators. Chain filters for precise queries.


Fast

Optimized for Analytics

ClickHouse-powered backend handles large datasets efficiently. Count endpoint optimized for aggregations.

Everything Included

Query events with flexible filtering
Count events matching any criteria
Filter by event properties and user attributes
Date range filtering (after/before)
Pagination for large result sets
List all distinct event names
Multiple comparison operators (equals, contains, greater than, etc.)
API key authentication with permissions
JSON response format

Perfect For

Real-world scenarios where it shines

Custom Dashboards

Build internal analytics dashboards with your favorite tools. Fetch data, visualize trends, and monitor KPIs in real-time.

Product TeamsExecutivesData Science

Data Exports & Warehouse

Schedule automated exports to your data warehouse. Sync analytics data to BigQuery, Snowflake, or your database for deep analysis.

Data EngineeringAnalyticsBI Tools

Automated Reports

Generate weekly or monthly reports automatically. Email stakeholders with key metrics and insights without manual work.

MarketingOperationsManagement

Embedded Analytics

Power customer-facing analytics in your SaaS product. Give users insights into their usage and behavior.

SaaSCustomer SuccessProduct

Ready to query your data?

Start building with the Query API today. Full access on Builder and higher plans.

Free forever • 15,000 active users per month • No credit card required