Chilkat Online Tools

Objective-C / Cognite API v1 / Retrieve data points

Back to Collection Items

#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;

// 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
// }

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"items[0].externalId" value: @"ut culpa Excepteur"];
[json UpdateInt: @"items[0].start" value: [NSNumber numberWithInt: 0]];
[json UpdateInt: @"items[0].end" value: [NSNumber numberWithInt: -12222847]];
[json UpdateInt: @"items[0].limit" value: [NSNumber numberWithInt: 43358925]];
[json UpdateString: @"items[0].aggregates[0]" value: @"interpolation"];
[json UpdateString: @"items[0].aggregates[1]" value: @"max"];
[json UpdateString: @"items[0].granularity" value: @"a"];
[json UpdateBool: @"items[0].includeOutsidePoints" value: NO];
[json UpdateString: @"items[1].externalId" value: @"aliquip"];
[json UpdateInt: @"items[1].start" value: [NSNumber numberWithInt: 0]];
[json UpdateInt: @"items[1].end" value: [NSNumber numberWithInt: -6309638]];
[json UpdateInt: @"items[1].limit" value: [NSNumber numberWithInt: 57543521]];
[json UpdateString: @"items[1].aggregates[0]" value: @"max"];
[json UpdateString: @"items[1].aggregates[1]" value: @"min"];
[json UpdateString: @"items[1].granularity" value: @""];
[json UpdateBool: @"items[1].includeOutsidePoints" value: NO];
[json UpdateString: @"start" value: @"velit"];
[json UpdateInt: @"end" value: [NSNumber numberWithInt: 50328109]];
[json UpdateInt: @"limit" value: [NSNumber numberWithInt: 100]];
[json UpdateString: @"aggregates[0]" value: @"count"];
[json UpdateString: @"aggregates[1]" value: @"max"];
[json UpdateString: @"granularity" value: @"mollit dolore"];
[json UpdateBool: @"includeOutsidePoints" value: NO];
[json UpdateBool: @"ignoreUnknownIds" value: NO];

[http SetRequestHeader: @"content-type" value: @"application/json"];
[http SetRequestHeader: @"api-key" value: @"{{api-key}}"];

CkoHttpResponse *resp = [http PostJson3: @"https://domain.com/api/v1/projects/{{project}}/timeseries/data/list" contentType: @"application/json" json: json];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

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}"
    }
  }
}