Skip to main content

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://data.qpos.me/cubejs-api/v1

Authentication

Start by obtaining an access token. The access token must be 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://data.qpos.me/cubejs-api/v1/load?query={"measures":["Orders.count"]}' \
--header 'Authorization: Bearer eyJhbGciOi...'\

Response example

{
"data": [
{
"Orders.count": 19461
}
],
"query": {
...
}
}

Examples

Get list of orders

curl --request GET 'https://data.qpos.me/cubejs-api/v1/load?query={"dimensions": ["Orders.createdAt", "Orders.paidAt", "Orders.status", "Orders.total"], "limit": 2, "order": [["Orders.paidAt", "desc"]]}' \
--header 'Authorization: Bearer eyJhbGciOiJSUz...' \
--header 'Content-Type: application/x-www-form-urlencoded'
{
"data": [
{
"Orders.createdAt": "2021-12-28T02:41:46.879",
"Orders.paidAt": "2021-12-28T02:51:22.997",
"Orders.status": "paid",
"Orders.total": 583
},
{
"Orders.createdAt": "2021-12-21T09:11:10.618",
"Orders.paidAt": "2021-12-27T09:18:07.570",
"Orders.status": "paid",
"Orders.total": 605
}
],
"query": {
...
},
}

Get list of line items with order and quantity in date range

curl --request GET 'https://data.qpos.me/cubejs-api/v1/load?query={"dimensions": ["Orders.id", "Orders.createdAt", "Orders.paidAt", "Orders.status", "Orders.total", "MenuProducts.name", "LineItems.quantity"], "filters": [{"member": "Orders.paidAt", "operator": "inDateRange", "values": ["2021-10-01", "2021-11-01"] }], "order": [["Orders.paidAt", "asc"]], "limit": 3}' \
--header 'Authorization: Bearer eyJhbGciOi...'
{
"data": [
{
"Orders.id": "35l1DE7ut7U6OQhXsOHb",
"Orders.createdAt": "2021-10-01T08:35:15.872",
"Orders.paidAt": "2021-10-01T08:35:32.019",
"Orders.status": "paid",
"Orders.total": 847,
"MenuProducts.name": "Espresso ",
"LineItems.quantity": 1
},
{
"Orders.id": "35l1DE7ut7U6OQhXsOHb",
"Orders.createdAt": "2021-10-01T08:35:15.872",
"Orders.paidAt": "2021-10-01T08:35:32.019",
"Orders.status": "paid",
"Orders.total": 847,
"MenuProducts.name": "Pour Over standard",
"LineItems.quantity": 1
},
{
"Orders.id": "35l1DE7ut7U6OQhXsOHb",
"Orders.createdAt": "2021-10-01T08:35:15.872",
"Orders.paidAt": "2021-10-01T08:35:32.019",
"Orders.status": "paid",
"Orders.total": 847,
"MenuProduct.name": "墨西哥捲餅 Quesadilla ",
"LineItems.quantity": 1
}
],
"query": {
...
}
}