Skip to main content

Base URL

All Query API endpoints are available at:

Authentication

All Query API requests require authentication via the X-API-Key header:

Creating an API Key

  1. Navigate to Dashboard → Settings → Authentication
  2. Click Generate New Secret
  3. Enter a descriptive name
  4. Check the “Query API” permission
  5. Copy the generated secret (it’s only shown once!)
Authentication Strategy: The Query API authentication is independent of your SDK authentication strategy. You can use Query API keys regardless of whether your SDK is set to NONE, SERVER_SIDE, or JWT authentication.
Store your API key securely in environment variables. Never commit it to version control or expose it in client-side code.

Endpoints

Important: Use your tenant alias (shown on the dashboard) as the {tenantId} parameter, not the UUID. The alias is the human-readable identifier you see in your dashboard.

Rate Limits

Rate limits are enforced per API key and vary by plan:
Need Higher Limits? These rate limits are designed for typical analytics use cases. For high-frequency applications, real-time dashboards, or bulk data exports, we offer custom plans with higher limits. Contact us at support@grainql.com to discuss your requirements.

Rate Limit Headers

When you approach your rate limit, responses include helpful headers:
When you exceed your rate limit, you’ll receive a 429 Too Many Requests response with a Retry-After header:

Error Handling

The Query API uses standard HTTP status codes and returns JSON error responses:

401 Unauthorized

Missing or invalid API key:

403 Forbidden

Insufficient plan tier:

429 Too Many Requests

Rate limit exceeded:

400 Bad Request

Invalid request parameters:

404 Not Found

Tenant not found:

Request/Response Format

Content Type

All requests must include:

Date Format

Dates should be in ISO 8601 format (YYYY-MM-DD):

Pagination

Use pagination to handle large result sets:
  • offset: Number of records to skip (0-based)
  • size: Maximum number of records to return (max: 1000)

Response Format

Query responses return an array of event objects:
Count responses return a simple object:

Common Patterns

Basic Query

Filtered Query

Count Query

List Events

SDK Integration

While the Query API works with any HTTP client, you can also use it with the Grain Analytics SDK for a more integrated experience:

Custom Plans

Need higher rate limits or have specific usage requirements? We offer custom plans tailored to your needs:
  • Higher rate limits: Custom requests per minute/day limits
  • Dedicated support: Priority support and SLA guarantees
  • Custom features: Tailored analytics features and integrations
  • Volume discounts: Competitive pricing for high-volume usage
Contact us at support@grainql.com to discuss your requirements and get a custom quote.

Next Steps

Query Events

Learn how to query events with filters

Count Events

Get event counts for aggregations

List Events

Discover available event types

Filter Reference

Complete filter operators guide