Chilkat Online Tools

unicodeCpp / Braze Endpoints / App Sessions by Time

Back to Collection Items

#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>

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

    CkHttpW http;
    bool success;

    CkJsonObjectW queryParams;
    queryParams.UpdateInt(L"length",14);
    queryParams.UpdateString(L"unit",L"day");
    queryParams.UpdateString(L"ending_at",L"2018-06-28T23:59:59-5:00");
    queryParams.UpdateString(L"app_id",L"{{app_identifier}}");
    queryParams.UpdateString(L"segment_id",L"{{segment_identifier}}");

    // Adds the "Authorization: Bearer {{api_key}}" header.
    http.put_AuthToken(L"{{api_key}}");

    CkHttpResponseW *resp = http.QuickRequestParams(L"GET",L"https://rest.iad-01.braze.com/sessions/data_series",queryParams);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    wprintf(L"%d\n",resp->get_StatusCode());
    wprintf(L"%s\n",resp->bodyStr());
    delete resp;
    }

Curl Command

curl -G -d "length=14"
	-d "unit=day"
	-d "ending_at=2018-06-28T23%3A59%3A59-5%3A00"
	-d "app_id=%7B%7Bapp_identifier%7D%7D"
	-d "segment_id=%7B%7Bsegment_identifier%7D%7D"
	-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/sessions/data_series

Postman Collection Item JSON

{
  "name": "App Sessions by Time",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/sessions/data_series?length=14&unit=day&ending_at=2018-06-28T23:59:59-5:00&app_id={{app_identifier}}&segment_id={{segment_identifier}}",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "sessions",
        "data_series"
      ],
      "query": [
        {
          "key": "length",
          "value": "14",
          "description": "(Required) Integer\n\nMax number of units (days or hours) before ending_at to include in the returned series - must be between 1 and 100 inclusive."
        },
        {
          "key": "unit",
          "value": "day",
          "description": "(Optional) String\n\nUnit of time between data points - can be \"day\" or \"hour\" (defaults to \"day\"). "
        },
        {
          "key": "ending_at",
          "value": "2018-06-28T23:59:59-5:00",
          "description": "(Optional) DateTime (ISO 8601 string)\n\nPoint in time when the data series should end - defaults to time of the request."
        },
        {
          "key": "app_id",
          "value": "{{app_identifier}}",
          "description": "(Optional) String\n\nApp API identifier retrieved from the Developer Console to limit analytics to a specific app."
        },
        {
          "key": "segment_id",
          "value": "{{segment_identifier}}",
          "description": "(Optional) String\n\nSegment API identifier indicating the analytics enabled segment for which sessions should be returned."
        }
      ]
    },
    "description": "This endpoint allows you to retrieve a series of the number of sessions for your app over a designated time period.\n\n### Components Used\n- [Segment Identifier](https://www.braze.com/docs/api/identifier_types/)\n\n## Response\n\n```json\nContent-Type: application/json\nAuthorization: Bearer YOUR-REST-API-KEY\n{\n    \"message\": (required, string) the status of the export, returns 'success' when completed without errors,\n    \"data\" : [\n        {\n            \"time\" : (string) point in time - as ISO 8601 extended when unit is \"hour\" and as ISO 8601 date when unit is \"day\",\n            \"sessions\" : (int)\n        },\n        ...\n    ]\n}\n```"
  },
  "response": [
  ]
}