Base URL
All Query API endpoints are available at:Authentication
All Query API requests require authentication via theX-API-Key header:
Creating an API Key
- Navigate to Dashboard → Settings → Authentication
- Click Generate New Secret
- Enter a descriptive name
- Check the “Query API” permission
- 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.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /{tenantId} | Query events with filters and pagination |
POST | /count/{tenantId} | Get count of events matching filters |
GET | /events/{tenantId} | List all distinct event names |
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:| Plan | Requests per Minute | Requests per Day |
|---|---|---|
| Free | Not available | Not available |
| Builder | 2 | 20 |
| Growth | 10 | 200 |
| Scale | 100 | 2,000 |
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 [email protected] to discuss your requirements.
Rate Limit Headers
When you approach your rate limit, responses include helpful headers: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: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