Perform advanced queries to fetch data that meets certain conditions. Provide a SelectQuery
in the request body.
Endpoint
Method | Endpoint | Query Params | Description |
---|
PUT | /data/{databaseId}/query/{MyTable} | pageSize (optional): number of records per page (max 1000) nextPage (optional): token for retrieving the next page of results | Query data with optional paging. |
SelectQuery Structure
Field | Description |
---|
fields (optional) | Array of field names to return. |
conditions (optional) | A condition that defines filtering logic. |
sort (optional) | Sort results by a specified field. |
limit (optional) | Limit the number of returned records. |
distinct (optional) | If true, returns only unique results. |
groupBy (optional) | Groups results by specified fields. |
Paging Support
When specifying a pageSize
parameter, if the total records exceed the specified pageSize, the results will be returned in pages. The response will include a nextPage
token if more records remain. To retrieve subsequent pages, send another request with the nextPage
token as a query parameter.
- If
pageSize
is greater than 1000, a 400 Bad Request is returned with an error message. - If the provided
nextPage
token is invalid or expired, a 404 Not Found is returned. - If
nextPage
is omitted, a fresh query is executed and, if needed, caching and paging are set up.
QueryCriteriaOperator
Operators define how to match field values (e.g., EQUAL, NOT_EQUAL, IN, LIKE, etc.).
EQUAL
NOT_EQUAL
IN
NOT_IN
GREATER_THAN
GREATER_THAN_EQUAL
LESS_THAN
LESS_THAN_EQUAL
MATCHES
NOT_MATCHES
BETWEEN
LIKE
NOT_LIKE
CONTAINS
NOT_CONTAINS
STARTS_WITH
NOT_STARTS_WITH
IS_NULL
NOT_NULL
Example (Without Paging)
Query all records where name
equals "Sample Entity":
PUT https://api.onyx.dev/data/{databaseId}/query/{MyTable}
Content-Type: application/json
x-onyx-key: YOUR_KEY
x-onyx-secret: YOUR_SECRET
{
"conditions": {
"criteria": {
"field": "name",
"operator": "EQUAL",
"value": "Sample Entity"
}
}
}
Response:
HTTP/1.1 201 Created
Content-Type: application/json
{
"records": [
{
"id": "123",
"name": "Sample Entity",
"description": "A descriptive sample entity."
}
],
"totalRecords": 1,
"nextPage": null
}
Example (With Paging)
Suppose you have many matching records and want them in batches of 50. Set pageSize=50
:
PUT https://api.onyx.dev/data/{databaseId}/query/{MyTable}?pageSize=50
Content-Type: application/json
x-onyx-key: YOUR_KEY
x-onyx-secret: YOUR_SECRET
{
"conditions": {
"criteria": {
"field": "status",
"operator": "EQUAL",
"value": "Active"
}
}
}
Response (First Page):
HTTP/1.1 201 Created
Content-Type: application/json
{
"records": [
{ "id": "100", "name": "Entity A", "status": "Active" },
{ "id": "101", "name": "Entity B", "status": "Active" },
...
// 50 records total
],
"totalRecords": 2000,
"nextPage": "a1b2c3d4|1" // A token to fetch the next page
}
To fetch the next page, use the returned nextPage
token:
PUT https://api.onyx.dev/data/{databaseId}/query/{MyTable}?nextPage=a1b2c3d4|1
Content-Type: application/json
x-onyx-key: YOUR_KEY
x-onyx-secret: YOUR_SECRET
This will return the next batch of 50 records and possibly another nextPage
token if more records remain.