Base URL
https://queryapis.grainql.com/v1/api/queryAuthentication
Every request carries an API key in theX-API-Key header and a JSON content type.
- Open
https://grainql.com/dashboard/settings, then Authentication. - Click Generate New Secret.
- Enter a name for the key.
- Select the Query API permission.
- Copy the secret. The dashboard shows it one time.
authStrategy. The key works when the
SDK uses NONE, SERVER_SIDE, or JWT. Read Authentication.
Endpoints
{tenantAlias} is the tenant alias that the dashboard shows. It is not the tenant UUID. A UUID
in the path returns 404.
Filters are the same on the query and count endpoints. Read
Filters.
The Query API does not write events. Send events with the Grain Tag or Analytics Web. Analytics
Web has no Query API methods, so call these endpoints with an HTTP client.
Rate limits
The limit applies per API key. The plan sets the limit.
Custom plans with higher limits exist.
Rate limit headers
A response near the limit carries three headers:
A request over the limit gets
429 and a Retry-After header with a number of seconds:
429, wait Retry-After seconds, then retry the request one time.
Errors
Every error body is a JSON object with oneerror string.
A filter with an unknown property path, an unknown operator, or a value of the wrong type also
returns an error body. Read Filters.
Request format
The twoPOST endpoints take a JSON body. GET /events/{tenantAlias} takes no body.
Response format
POST /{tenantAlias} returns an array of event objects:
POST /count/{tenantAlias} returns one object:
GET /events/{tenantAlias} returns an array of strings: