Query Exports
The platform allows you to export data as ndjson
, based on OTQL queries. This action is available in the navigator or through API to automate the process.
For punctual exports, you may want to use the navigator (in Data Studio > Exports) rather than our API for more simplicity.
An export is a definition with:
a name
an output format (always
JSON
for now)a type (always
QUERY
for now)an associated query
an associated organisation
an associated datamart
Each export has executions representing its result at a given time.
An execution goes through different stages:
Pending
if the export is not startedRunning
if the export is startedSucceeded
orFailed
once the export has been completed
The resulting file is formatted in ndjson
, and contains the properties you selected in the SELECT
part of the OTQL query.
Listing exports
GET
https://api.mediarithmics.com/v1/exports?organisation_id=:orgId
Path Parameters
Name | Type | Description |
---|---|---|
orgId | integer | The ID of the organisation for which you want to list exports |
Details of an export
GET
https://api.mediarithmics.com/v1/exports/:exportId?organisation_id=:orgId
Path Parameters
Name | Type | Description |
---|---|---|
exportId | integer | The ID of the export |
orgId | integer | The ID of the organisation containing the export |
Create an export
You will first need to create a query for your export.
You should check your query and verify its results before creating an export. It is easier to do at this step, as the export would only return an empty file and no message.
Create an export
POST
https://api.mediarithmics.com/v1/exports?organisation_id=:orgId
Path Parameters
Name | Type | Description |
---|---|---|
orgId | integer | The ID of the organisation |
Request Body
Name | Type | Description |
---|---|---|
Body | string | the request payload |
Generate an execution
POST
https://api.mediarithmics.com/v1/exports/:exportId/executions
Path Parameters
Name | Type | Description |
---|---|---|
exportId | integer | The ID of the export |
Request Body
Name | Type | Description |
---|---|---|
Body | object | Must be an empty JSON object : |
Execution status
GET
https://api.mediarithmics.com/v1/exports/:exportId/executions
Path Parameters
Name | Type | Description |
---|---|---|
exportId | integer | The ID of the export |
If available, the technical name of the file to download is in the result.output_files
array
Download the result of an export
The result of an export is saved as a data file in the platform.
You have two methods to retrieve it :
Using the exports API (recommended)
Using the data_file API
Download using the exports API
GET
https://api.mediarithmics.com/v1/exports/:exportId/executions/:executionId/files/technical_name=:technicalName
Path Parameters
Name | Type | Description |
---|---|---|
exportId | integer | The ID of the export |
executionId | integer | The ID of the execution for which to download the report |
Query Parameters
Name | Type | Description |
---|---|---|
technical_name | string | The name of the file(s) in the |
Download using the data_file API
GET
https://api.mediarithmics.com/v1/data_file/data?uri=mics://data_file/tenants/:organisationId/jobs/executions/:executionId/result/export.data
Query Parameters
Name | Type | Description |
---|---|---|
executionId | string | The ID of the execution |
organisationId | integer | The ID of the organisation |
Download the error file
GET
https://api.mediarithmics.com/v1/data_file/data?uri=mics://data_file/tenants/:organisationId/jobs/executions/:executionId/result/export.error
Use this endpoint in case of a FAILED
execution status.
Query Parameters
Name | Type | Description |
---|---|---|
executionId | string | The ID of the execution |
organisationId | integer | The ID of the organisation |
Last updated