Ordering metrics arrays by date


#1

I’m pulling four days worth of data from the Twitter Ads API. The metrics are returned in an array with a value for each day. How am I supposed to know which day each item corresponds to? I haven’t found the answer in documentation and the sort_by parameter doesn’t appear to have any effect (it doesn’t show up in the request/params section of the response and the values are displayed in the same order regardless of whether I use asc or desc).

This twurl command:

twurl -H "ads-api.twitter.com" "/2/stats/accounts/r4ge93?sort_by=start_time-desc&entity=CAMPAIGN&entity_ids=9nlj9&granularity=DAY&metric_groups=ENGAGEMENT&start_time=2017-10-26&end_time=2017-10-30&placement=ALL_ON_TWITTER" | jq .

Yields this response:

{
  "data_type": "stats",
  "time_series_length": 4,
  "data": [
    {
      "id": "9nlj9",
      "id_data": [
        {
          "segment": null,
          "metrics": {
            "impressions": [
              161715,
              145296,
              167610,
              193796
            ],
            "tweets_send": [
              0,
              0,
              0,
              1
            ],
            "qualified_impressions": null,
            "follows": [
              0,
              0,
              1,
              1
            ],
            "app_clicks": null,
            "retweets": null,
            "likes": [
              7,
              7,
              10,
              6
            ],
            "engagements": [
              547,
              462,
              601,
              577
            ],
            "clicks": [
              320,
              284,
              370,
              384
            ],
            "card_engagements": null,
            "poll_card_vote": null,
            "replies": null,
            "url_clicks": null,
            "carousel_swipes": null
          }
        }
      ]
    }
  ],
  "request": {
    "params": {
      "start_time": "2017-10-26T07:00:00Z",
      "segmentation_type": null,
      "entity_ids": [
        "9nlj9"
      ],
      "end_time": "2017-10-30T07:00:00Z",
      "country": null,
      "placement": "ALL_ON_TWITTER",
      "granularity": "DAY",
      "entity": "CAMPAIGN",
      "platform": null,
      "metric_groups": [
        "ENGAGEMENT"
      ]
    }
  }
}

#2

Hi @sq-marquam -

The data should follow chronological order with date.
IE. 10/26 imps = 161715, 10/29 imps = 193796.