Reporting API
Access to the reporting API is handle by cube.js which allows for optimal performance, pre-aggregation and access control. Request can be done through a REST API or any of the provided client libraries such as React, Vue or Web sockets. See [https://cube.dev/docs/frontend-introduction] for more details on available integration libraries.
REST API
Request base url
https://qapi.qpos.me/cubejs-api/v1
Authentication
Start by obtaining an access token. The access token must b e included in the header for all requests. See the previous chapter for more information.
A request can also include a query param that is interpreted by the API, translated to SQL and which returns a response with the relevant json data.
Request example
A simple request to count all orders
curl --request GET 'https://qapi.qpos.me/cubejs-api/v1/load?query={"measures":["orders.count"]}' \
--header 'Authorization: Bearer eyJhbGciOi...'\
Response example
{
"data": [
{
"orders.count": 19461
}
],
"query": {
...
}
}
Meta data
Retrieve a list of all cubes, dimensions and measures
https://qapi.qpos.me/cubejs-api/v1/meta
Examples
Get list of orders
curl --request GET 'https://qapi.qpos.me/cubejs-api/v1/load?query={"dimensions": ["orders.paid_at", "orders.status", "orders.amount"], "limit": 2, "order": [["orders.paid_at", "desc"]]}' \
--header 'Authorization: Bearer eyJhbGciOiJSUz...' \
--header 'Content-Type: application/x-www-form-urlencoded'
{
"data": [
{
"orders.paid_at": "2023-10-18T02:37:01.234",
"orders.status": "paid",
"orders.amount": 150
},
{
"orders.paid_at": "2023-09-01T04:46:30.896",
"orders.status": "paid",
"orders.amount": 180
}
],
"query": {
...
},
}
Get list of line items with order and quantity in date range
curl --request GET 'https://qapi.qpos.me/cubejs-api/v1/load?query={"dimensions": ["orders.id", "orders.paid_at", "orders.status", "orders.amount","menu_products.name", "menu_variants.name", "line_items.quantity"], "filters": [{"member": "orders.paid_at", "operator": "inDateRange", "values": ["2023-10-01", "2023-11-01"] }], "order": [["orders.paid_at", "asc"]], "limit": 3}' \
--header 'Authorization: Bearer eyJhbGciOi...'
{
"data": [
{
"orders.id": "4WGOlrQUA9Tq8-HA6cGBtC",
"orders.paid_at": "2023-10-18T02:37:01.234",
"orders.status": "paid",
"orders.amount": 150,
"menu_products.name": "Coffee",
"menu_variants.name": "Large",
"line_items.quantity": 1
}
],
"query": {
...
}
}