Explore timeseries
Get time series dataset¶
All time series datasets are registered by their ID in the metadata service. In the time series service, the GET/api/ts/dataset/{id}
endpoint provides time series dataset details.
Click to show example shell script
projectid="<replacewithprojectid>" openapikey="<replacewithopenapikey>" datasetid="<replacewithdatasetid>" curl -L -X GET "https://api.mike-cloud-test.com/api/ts/dataset/$datasetid" \ -H 'Content-Type: application/json' \ -H "dhi-open-api-key: $openapikey" \ -H "dhi-service-id: timeseries" \ -H "dhi-project-id: $projectid" \ -H "dhi-dataset-id: $datasetid"
Click to show example response
{ "id": "e061ac0b-f44e-4d5f-8bd0-82dc1848e6a3", "items": [ { "name": "TestItem", "unit": "eumUUnitUndefined", "item": "eumIItemUndefined", "dataType": "Single", "timeSeriesType": "Instantaneous" } ], "timeSeriesProperties": [ { "name": "CX", "dataType": "Double" }, { "name": "CY", "dataType": "Double" } ], "metadata": {} }
Get time series details and data¶
Details about existing time series and actual data can be obtained using endpoints below.
To get time series details use:
GET/api/ts/dataset/{id}/timeseries/{timeSeriesId}
Click to show example shell script
projectid="<replacewithprojectid>" openapikey="<replacewithopenapikey>" datasetid="<replacewithdatasetid>" timeseriesid="<replacewithtimeseriesid>" curl -k -X GET \ "https://api.mike-cloud-test.com/api/ts/dataset/$datasetid/timeseries/$timeseriesid" \ -H 'Content-Type: application/json' \ -H "dhi-service-id: timeseries" \ -H "dhi-project-id: $projectid" \ -H "dhi-dataset-id: $datasetid" \ -H "dhi-open-api-key: $openapikey"
Click to show example response
{ "id": "f3a12147-5276-4ed7-a322-31554656f72c", "item": { "name": "TestItem", "unit": "eumUUnitUndefined", "item": "eumIItemUndefined", "dataType": "Single", "timeSeriesType": "Instantaneous" }, "properties": { "CX": 1.1, "CY": 2.2 }, "dataFields": [ { "name": "DfSingle", "dataType": "Single" }, { "name": "Quality", "dataType": "Flag", "flags": [ { "id": 0, "name": "Bad", "level": 0 }, { "id": 1, "name": "Ok", "level": 0 }, { "id": 2, "name": "Semi", "level": 0 } ] } ] }
To get values and flags of time series use:
GET/api/ts/dataset/{id}/timeseries/{timeSeriesId}/values
Click to show example shell script
projectid="<replacewithprojectid>" openapikey="<replacewithopenapikey>" datasetid="<replacewithdatasetid>" timeseriesid="<replacewithtimeseriesid>" # get time steps from January 1, 2010, 00:00:00 to February 1, 2010, 00:00:00 dtfrom="2010-01-01T000000" dtto="2010-02-01T000000" # get values from one time series curl -k -X GET \ "https://api.mike-cloud-test.com/api/ts/dataset/$datasetid/timeseries/$timeseriesid/values?from=$dtfrom&to=$dtto" \ -H 'Content-Type: application/json' \ -H "dhi-service-id: timeseries" \ -H "dhi-project-id: $projectid" \ -H "dhi-dataset-id: $datasetid" \ -H "dhi-open-api-key: $openapikey"
Click to show example response
{ "data": [ [ "2016-05-01T00:00:00", 10000000.0, 2 ], [ "2016-05-01T00:01:00", 100.5, 2 ], [ "2016-05-01T00:02:00", 100.5, 2 ] ] }
or
POST/api/ts/dataset/{id}/timeseries/values
Click to show example shell script
projectid="<replacewithprojectid>" openapikey="<replacewithopenapikey>" datasetid="<replacewithdatasetid>" timeseriesid="<replacewithtimeseriesid>" # get time steps from January 1, 2010, 00:00:00 to February 1, 2010, 00:00:00 dtfrom="2010-01-01T000000" dtto="2010-02-01T000000" # array with three time series ids arrayids="[\"7096E557-FD61-46E5-BD63-B4BD61A3AD30\", \ \"4051CE9E-86FD-411D-B7D9-1DDE15F00DDC\", \ \"1AE92295-3FEE-485A-B40B-17D249880254\"]" # get values from three time series curl -k -X POST \ "https://api.mike-cloud-test.com/api/ts/dataset/$datasetid/timeseries/values?from=$dtfrom&to=$dtto" \ -H 'Content-Type: application/json' \ -H "dhi-service-id: timeseries" \ -H "dhi-project-id: $projectid" \ -H "dhi-dataset-id: $datasetid" \ -H "dhi-open-api-key: $openapikey" \ -d "$arraytsids"
Click to show example response
{ "data": [ [ [ "2016-05-01T00:00:00", 10000000.0, 2 ], [ "2016-05-01T00:01:00", 100.5, 2 ], [ "2016-05-01T00:02:00", 100.5, 2 ] ] ] }
Two endpoints above have optional filter parameters from
and to
where the expected time format is yyyy-MM-ddTHHmmss
. To list all time series in a dataset use GET/api/ts/dataset/{id}/timeseries/list
.
Click to show example shell script
projectid="<replacewithprojectid>" openapikey="<replacewithopenapikey>" datasetid="<replacewithdatasetid>" curl -L -X GET "https://api.mike-cloud-test.com/api/ts/dataset/$datasetid/timeseries/list" \ -H 'Content-Type: application/json' \ -H "dhi-service-id: timeseries" \ -H "dhi-project-id: $projectid" \ -H "dhi-dataset-id: $datasetid" \ -H "dhi-open-api-key: $openapikey" \ --data-raw ""
Click to show example response
{ "data": [ { "id": "f3a12147-5276-4ed7-a322-31554656f72c", "item": { "name": "TestItem", "unit": "eumUUnitUndefined", "item": "eumIItemUndefined", "dataType": "Single", "timeSeriesType": "Instantaneous" }, "properties": {}, "dataFields": [ { "name": "DfSingle", "dataType": "Single" }, { "name": "Quality", "dataType": "Flag", "flags": [ { "id": 0, "name": "Bad", "level": 0 }, { "id": 1, "name": "Ok", "level": 0 }, { "id": 2, "name": "Semi", "level": 0 } ] } ] } ] }
Query time series¶
You can also list only time series that match certain criteria using
POST/api/ts/dataset/{id}/timeseries/query
.
Click to show example shell script
projectid="<replacewithprojectid>" openapikey="<replacewithopenapikey>" datasetid="<replacewithdatasetid>" curl -L -X POST "https://api.mike-cloud-test.com/api/ts/dataset/$datasetid/timeseries/query" \ -H 'Content-Type: application/json' \ -H "dhi-service-id: timeseries" \ -H "dhi-project-id: $projectid" \ -H "dhi-dataset-id: $datasetid" \ -H "dhi-open-api-key: $openapikey" \ --data-raw "{ \"conditions\": [ { \"type\": \"AttributeQueryCondition\", \"name\": \"Item\", \"operator\": \"Equal\", \"value\": \"TestItem\" }, { \"type\": \"AttributeQueryCondition\", \"name\": \"CX\", \"operator\": \"Equal\", \"value\": \"1\" } ] }"
Click to show example response
{ "data": [ { "id": "05f8141e-5a6f-4b89-aee6-774431f90970", "item": { "name": "TestItem", "unit": "eumUUnitUndefined", "item": "eumIItemUndefined", "dataType": "Single", "timeSeriesType": "Instantaneous" }, "properties": { "CX": 1.0 }, "dataFields": [ { "name": "DfSingle", "dataType": "Single" }, { "name": "Quality", "dataType": "Flag", "flags": [ { "id": 0, "name": "Bad", "level": 0 }, { "id": 1, "name": "Ok", "level": 0 }, { "id": 2, "name": "Semi", "level": 0 } ] } ] } ] }