Chilkat Online Tools

Node.js / Braze Endpoints / News Feed Card Analytics

Back to Collection Items

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}


function chilkatExample() {

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

    var http = new chilkat.Http();
    var success;

    var queryParams = new chilkat.JsonObject();
    queryParams.UpdateString("card_id","{{card_identifier}}");
    queryParams.UpdateInt("length",14);
    queryParams.UpdateString("unit","day");
    queryParams.UpdateString("ending_at","2018-06-28T23:59:59-5:00");

    // Adds the "Authorization: Bearer {{api_key}}" header.
    http.AuthToken = "{{api_key}}";

    // resp: HttpResponse
    var resp = http.QuickRequestParams("GET","https://rest.iad-01.braze.com/feed/data_series",queryParams);
    if (http.LastMethodSuccess == false) {
        console.log(http.LastErrorText);
        return;
    }

    console.log(resp.StatusCode);
    console.log(resp.BodyStr);


}

chilkatExample();

Curl Command

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

Postman Collection Item JSON

{
  "name": "News Feed Card Analytics",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/feed/data_series?card_id={{card_identifier}}&length=14&unit=day&ending_at=2018-06-28T23:59:59-5:00",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "feed",
        "data_series"
      ],
      "query": [
        {
          "key": "card_id",
          "value": "{{card_identifier}}",
          "description": "(Required) String\n\nCard API identifier"
        },
        {
          "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\nDate on which the data series should end - defaults to time of the request"
        }
      ]
    },
    "description": "This endpoint allows you to retrieve a daily series of engagement stats for a card over time.\n\n### Components Used\n- [Card ID](https://www.braze.com/docs/api/identifier_types/)\n- [News Feed List](https://www.braze.com/docs/api/endpoints/export/news_feed/get_news_feed_cards/)\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            \"clicks\" : (int) ,\n            \"impressions\" : (int),\n            \"unique_clicks\" : (int),\n            \"unique_impressions\" : (int)\n        },\n        ...\n    ]\n}\n```"
  },
  "response": [
  ]
}