Data analytics API

REST API - Access to the underlying data from Data Analytics or the widgets via API

API call

As soon as you configure a widget, you will find the API Call item in the side menu. This option is available for every widget.

Historic Parking Utilization Widget

Execute the call accordingly and test it directly in the dialog box, including the response format, by clicking _Try it out!

The dialog box that appears contains detailed information about what the API call looks like for this widget's data. Copy the code provided and use it as required.

API Call

Authentication

We strictly adhere to the OAuth flow documented by Microsoft. There are several Client Libraries that you can use.

Example of a request

Bicycle counting

Below you can see a widget in Data Analytics that is used for bicycle counting. The corresponding widget type (Traffic Counting) has been selected, the data is aggregated per tag, broken down by object class and direction and filtered by bicycles.

Bike count widget

API request

The API call shows the corresponding GET request for this data as shown below:

https://example.com/cubejs-api/v1/load?query=
{
   "measures":[
      "CrossingEvents.count"
   ],
   "dimensions":[
      "CrossingEvents.classification",
      "CrossingEvents.direction"
   ],
   "segments":[],
   "filters":[
      {
         "member":"CrossingEvents.streamId",
         "operator":"equals",
         "values":[
            "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
         ]
      },
      {
         "member":"CrossingEvents.classification",
         "operator":"contains",
         "values":[
            "bicycle"
         ]
      },
      {
         "member":"CrossingEvents.lineId",
         "operator":"equals",
         "values":[
            "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
         ]
      }
   ],
   "timeDimensions":[
      {
         "dimension":"CrossingEvents.timestamp",
         "granularity":"day",
         "dateRange":"This week"
      }
   ],
   "order":{}
}

API-Response:

{
  "queryType": "regularQuery",
  "results": [
    {
      "query": {...},
      "data": [
        {
          "CrossingEvents.classification": "bicycle",
          "CrossingEvents.direction": "in",
          "CrossingEvents.timestamp.day": "2021-11-02T00:00:00.000",
          "CrossingEvents.timestamp": "2021-11-02T00:00:00.000",
          "CrossingEvents.count": "235"
        },
        {
          "CrossingEvents.classification": "bicycle",
          "CrossingEvents.direction": "out",
          "CrossingEvents.timestamp.day": "2021-11-02T00:00:00.000",
          "CrossingEvents.timestamp": "2021-11-02T00:00:00.000",
          "CrossingEvents.count": "234"
        },
        {
          "CrossingEvents.classification": "bicycle",
          "CrossingEvents.direction": "in",
          "CrossingEvents.timestamp.day": "2021-11-03T00:00:00.000",
          "CrossingEvents.timestamp": "2021-11-03T00:00:00.000",
          "CrossingEvents.count": "203"
        },
        {
          "CrossingEvents.classification": "bicycle",
          "CrossingEvents.direction": "out",
          "CrossingEvents.timestamp.day": "2021-11-03T00:00:00.000",
          "CrossingEvents.timestamp": "2021-11-03T00:00:00.000",
          "CrossingEvents.count": "249"
        }
      ],
      "annotation": {...}
    }
  ],
  "pivotQuery": {...}
}

Extended documentation

The REST API is based on _Cube.js_. You can find more information and details about this and how it works in general in this external documentation.

Last updated