Chilkat Online Tools

PowerBuilder / Cognite API v1 / Retrieve data points

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

loo_Json.UpdateString("items[0].externalId","ut culpa Excepteur")
loo_Json.UpdateInt("items[0].start",0)
loo_Json.UpdateInt("items[0].end",-12222847)
loo_Json.UpdateInt("items[0].limit",43358925)
loo_Json.UpdateString("items[0].aggregates[0]","interpolation")
loo_Json.UpdateString("items[0].aggregates[1]","max")
loo_Json.UpdateString("items[0].granularity","a")
loo_Json.UpdateBool("items[0].includeOutsidePoints",0)
loo_Json.UpdateString("items[1].externalId","aliquip")
loo_Json.UpdateInt("items[1].start",0)
loo_Json.UpdateInt("items[1].end",-6309638)
loo_Json.UpdateInt("items[1].limit",57543521)
loo_Json.UpdateString("items[1].aggregates[0]","max")
loo_Json.UpdateString("items[1].aggregates[1]","min")
loo_Json.UpdateString("items[1].granularity","")
loo_Json.UpdateBool("items[1].includeOutsidePoints",0)
loo_Json.UpdateString("start","velit")
loo_Json.UpdateInt("end",50328109)
loo_Json.UpdateInt("limit",100)
loo_Json.UpdateString("aggregates[0]","count")
loo_Json.UpdateString("aggregates[1]","max")
loo_Json.UpdateString("granularity","mollit dolore")
loo_Json.UpdateBool("includeOutsidePoints",0)
loo_Json.UpdateBool("ignoreUnknownIds",0)

loo_Http.SetRequestHeader("content-type","application/json")
loo_Http.SetRequestHeader("api-key","{{api-key}}")

loo_Resp = loo_Http.PostJson3("https://domain.com/api/v1/projects/{{project}}/timeseries/data/list","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    return
end if

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Http
destroy loo_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}"
    }
  }
}