unicodeC / Cognite API v1 / Retrieve data points
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "items": [
// {
// "externalId": "ut culpa Excepteur",
// "start": 0,
// "end": -12222847,
// "limit": 43358925,
// "aggregates": [
// "interpolation",
// "max"
// ],
// "granularity": "a",
// "includeOutsidePoints": false
// },
// {
// "externalId": "aliquip",
// "start": 0,
// "end": -6309638,
// "limit": 57543521,
// "aggregates": [
// "max",
// "min"
// ],
// "granularity": "",
// "includeOutsidePoints": false
// }
// ],
// "start": "velit",
// "end": 50328109,
// "limit": 100,
// "aggregates": [
// "count",
// "max"
// ],
// "granularity": "mollit dolore",
// "includeOutsidePoints": false,
// "ignoreUnknownIds": false
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"items[0].externalId",L"ut culpa Excepteur");
CkJsonObjectW_UpdateInt(json,L"items[0].start",0);
CkJsonObjectW_UpdateInt(json,L"items[0].end",-12222847);
CkJsonObjectW_UpdateInt(json,L"items[0].limit",43358925);
CkJsonObjectW_UpdateString(json,L"items[0].aggregates[0]",L"interpolation");
CkJsonObjectW_UpdateString(json,L"items[0].aggregates[1]",L"max");
CkJsonObjectW_UpdateString(json,L"items[0].granularity",L"a");
CkJsonObjectW_UpdateBool(json,L"items[0].includeOutsidePoints",FALSE);
CkJsonObjectW_UpdateString(json,L"items[1].externalId",L"aliquip");
CkJsonObjectW_UpdateInt(json,L"items[1].start",0);
CkJsonObjectW_UpdateInt(json,L"items[1].end",-6309638);
CkJsonObjectW_UpdateInt(json,L"items[1].limit",57543521);
CkJsonObjectW_UpdateString(json,L"items[1].aggregates[0]",L"max");
CkJsonObjectW_UpdateString(json,L"items[1].aggregates[1]",L"min");
CkJsonObjectW_UpdateString(json,L"items[1].granularity",L"");
CkJsonObjectW_UpdateBool(json,L"items[1].includeOutsidePoints",FALSE);
CkJsonObjectW_UpdateString(json,L"start",L"velit");
CkJsonObjectW_UpdateInt(json,L"end",50328109);
CkJsonObjectW_UpdateInt(json,L"limit",100);
CkJsonObjectW_UpdateString(json,L"aggregates[0]",L"count");
CkJsonObjectW_UpdateString(json,L"aggregates[1]",L"max");
CkJsonObjectW_UpdateString(json,L"granularity",L"mollit dolore");
CkJsonObjectW_UpdateBool(json,L"includeOutsidePoints",FALSE);
CkJsonObjectW_UpdateBool(json,L"ignoreUnknownIds",FALSE);
CkHttpW_SetRequestHeader(http,L"content-type",L"application/json");
CkHttpW_SetRequestHeader(http,L"api-key",L"{{api-key}}");
resp = CkHttpW_PostJson3(http,L"https://domain.com/api/v1/projects/{{project}}/timeseries/data/list",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "api-key: {{api-key}}"
-H "content-type: application/json"
-d '{
"items": [
{
"externalId": "ut culpa Excepteur",
"start": 0,
"end": -12222847,
"limit": 43358925,
"aggregates": [
"interpolation",
"max"
],
"granularity": "a",
"includeOutsidePoints": false
},
{
"externalId": "aliquip",
"start": 0,
"end": -6309638,
"limit": 57543521,
"aggregates": [
"max",
"min"
],
"granularity": "",
"includeOutsidePoints": false
}
],
"start": "velit",
"end": 50328109,
"limit": 100,
"aggregates": [
"count",
"max"
],
"granularity": "mollit dolore",
"includeOutsidePoints": false,
"ignoreUnknownIds": false
}'
https://domain.com/api/v1/projects/{{project}}/timeseries/data/list
Postman Collection Item JSON
{
"id": "getMultiTimeSeriesDatapoints",
"name": "Retrieve data points",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"timeseries",
"data",
"list"
],
"query": [
],
"variable": [
]
},
"method": "POST",
"header": [
{
"key": "api-key",
"value": "{{api-key}}",
"description": "An admin can create API keys in the Cognite console."
},
{
"key": "content-type",
"value": "application/json"
}
],
"description": "Retrieves a list of data points from multiple time series in a project. This operation supports aggregation, but not pagination. A detailed description of how aggregates work can be found at [our concept guide for aggregation](<https://docs.cognite.com/dev/concepts/aggregation/>).",
"body": {
"mode": "raw",
"raw": "{\n \"items\": [\n {\n \"externalId\": \"ut culpa Excepteur\",\n \"start\": 0,\n \"end\": -12222847,\n \"limit\": 43358925,\n \"aggregates\": [\n \"interpolation\",\n \"max\"\n ],\n \"granularity\": \"a\",\n \"includeOutsidePoints\": false\n },\n {\n \"externalId\": \"aliquip\",\n \"start\": 0,\n \"end\": -6309638,\n \"limit\": 57543521,\n \"aggregates\": [\n \"max\",\n \"min\"\n ],\n \"granularity\": \"\",\n \"includeOutsidePoints\": false\n }\n ],\n \"start\": \"velit\",\n \"end\": 50328109,\n \"limit\": 100,\n \"aggregates\": [\n \"count\",\n \"max\"\n ],\n \"granularity\": \"mollit dolore\",\n \"includeOutsidePoints\": false,\n \"ignoreUnknownIds\": false\n}"
}
}
}