Skip to content

Modify timeseries

Update all time series properties

The PUT/api/ts/dataset/{id}/timeseries/{timeSeriesId} endpoint can be used for updating all the properties of a time series.

Click to show example shell script
projectid="<replacewithprojectid>"
openapikey="<replacewithopenapikey>"
datasetid="<replacewithdatasetid>"
timeseriesid="<replacewithtimeseriesid>"

curl -L -X PUT "https://api.mike-cloud-test.com/api/ts/dataset/$datasetid/timeseries/$timeSeriesid" \
  -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" \
  --data-raw "{
  \"properties\": {
    \"CX\": 1.1,
    \"CY\": 2.2
  }
}"

Update a single time series property

The PUT/api/ts/dataset/{id}/timeseries/{timeSeriesId}/property endpoint can be used for updating a single, given property of a time series.

Click to show example shell script
projectid="<replacewithprojectid>"
openapikey="<replacewithopenapikey>"
datasetid="<replacewithdatasetid>"
timeseriesid="<replacewithtimeseriesid>"

curl -L -X PUT "https://api.mike-cloud-test.com/api/ts/dataset/$datasetid/timeseries/$timeSeriesid/property" \
  -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" \
  --data-raw "{
  \"CX\": 1.1
}"

Append time series data in CSV format

You can add more time steps to a time series from CSV using POST/api/ts/dataset/{id}/timeseries/{timeSeriesId}/upload/csv

Click to show example shell script
projectid="<replacewithprojectid>"
openapikey="<replacewithopenapikey>"
datasetid="<replacewithdatasetid>"
timeseriesid="<replacewithtimeseriesid>"

curl -L -X POST "https://api.mike-cloud-test.com/api/ts/dataset/$datasetid/timeseries/$timeSeriesid/upload/csv" \
  -H 'Content-Type: text/plain' \
  -H "dhi-open-api-key: $openapikey" \
  -H "dhi-service-id: timeseries" \
  -H "dhi-project-id: $projectid" \
  -H "dhi-dataset-id: $datasetid" \
  --data-raw "2004-04-15 00:11:00;8.83297;6.27504
2004-04-15 00:12:00;10.56317E-07;6.27504"

Append time series data in JSON format

You can add more time steps to a time series from JSON using POST/api/ts/dataset/{id}/timeseries/{timeSeriesId}/upload/json

Click to show example shell script

projectid="<replacewithprojectid>"
openapikey="<replacewithopenapikey>"
datasetid="<replacewithdatasetid>"
timeseriesid="<replacewithtimeseriesid>"

payload="{ 
\"data\": [
    [\"2020-01-24T08:35:30\", 19.6726112857799],
    [\"2020-01-24T08:36:30\", 14.0582331894237]
  ]
}
"

curl -k -X POST https://api.mike-cloud-test.com/api/ts/dataset/$datasetid/timeseries/$timeSeriesid/upload/json \
  -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" \
  -d $payload

Note that you need to provide values for value but also for any flag the time series was defined with. For example, if time series contains a value and one flag, the update data may look like this:

    "data": [
        ["2020-01-24T08:35:30", 19.6726112857799, 2],
        ["2020-01-24T08:36:30", 14.0582331894237, 2]
    ]