Skip to content

OcStatisticsApi

FarbodZamani edited this page Mar 25, 2022 · 4 revisions

This class contains all REST API calls to the /api/statistics endpoint.

Namespace

It is accessible under OpencastApi\Rest namespace.

Version

This endpoint is available for API Version 1.3.0 or greater, therefore, it throws an Exception upon direct class instantiation, or it won't be defined as property in OpencastApi\OpenCast class when api version is incompatible!

How to use

  1. In OpencastApi\OpenCast as its property with OpenCast properties naming convention:
use OpencastApi\OpenCast;
$opencastApi = new OpenCast($config);
$ocStatisticsApi = $opencastApi->statisticsApi;
...
  1. Direct instantiation:
use OpencastApi\Rest\OcRestClient;
use OpencastApi\Rest\OcStatisticsApi;
$ocRestClient = new OcRestClient($config);
$ocStatisticsApi = new OcStatisticsApi($ocRestClient);
...

Functions

Consumable functions are listed below:

getAllProviders($filter = [], $withparameters = false)

Returns a list of statistics providers. Currently, only the "timeseries" type is supported! More Detail

  • $filter (array) (optional) an assiciative array for filtering e.g. ['resourceType' => '{resource type}']

  • $withparameters (boolean) (optional) Whether support parameters should be included in the response

  • Returns an array: ['code' => 200, 'body' => '{the requested statistics providers as JSON (array) }']

getProvider($providerId, $withparameters = false)

Returns a statistics provider. More Detail

  • $providerId (string) The identifier of the statistics provider

  • $withparameters (boolean) (optional) Whether support parameters should be included in the response

  • Returns an array: ['code' => 200, 'body' => '{The requested statistics provider}']

getStatisticalData($data)

Returns the statistical data based on the query posted. More Detail

  • $data (array) A JSON array describing the queries to be executed.

  • Returns an array: ['code' => 200, 'body' => '{The statistical data as JSON (array)}']

getStatisticalDataCSV($data, $params = [])

Retrieves statistical data in csv format. More Detail
Note that limit and offset relate to the resource here, not CSV lines.
There can be multiple lines in a CSV for a resource, e.g. an event.
However, you cannot limit by lines, but only by e.g. events.

  • $data (array) A JSON array describing the statistics queries to request.
  • $params is an optional array that could contain the following:
[
    'limit' => (int) {the maximum number of results to return},
    'offset' => (int) {the index of the first result to return},
    'filter' => (array) {an assiciative array for filtering. All standard dublin core meta data fields are filterable.},
]
  • Returns an array: ['code' => 200, 'body' => '{The requested statistics csv export}']