Is there an issue with my ads query?

ads
api

#1

Hi everyone,

I’ve been trying to retrieve information about a specific campaign using the synchronous calls. I can get a list of campaigns without a problem, but for some unknown reason I can’t get this query to work. I’ve tried changing the start and end times to the ISO 8601 structure and didn’t help. I keep getting null returns. I am using the Tweetinvi library and using its custom query function. I don’t think that’s too relevant as I’m mainly using the lib for the Oauth portion.

anything in {} is data that was removed for privacy purposes.

https://ads-api.twitter.com/2/stats/accounts/{account id}?entity=CAMPAIGN&entity_ids={campaign id}&start_time=2014-01-13&end_time=2015-03-01&granularity=TOTAL&placement=ALL_ON_TWITTER&metric_groups=ENGAGEMENT

Thanks in advance


#2

Hi @itdevfirstent,

The synchronous analytics endpoint returns up to 7 days of non-segmented data. Please review our documentation here for usage of synchronous vs asynchronous. Thanks!


#3

@itdevfirstent: Keep in mind that the date range matters. If you request data for a time period prior to when the entity was created, for example, you should expect to see null values.

As an example, the following line item was created on 2017-12-21.

$ twurl -H ads-api.twitter.com "/2/accounts/18ce54d4x5t/line_items/aq4uw"
{
  "request": {
    "params": {
      "line_item_id": "aq4uw",
      "account_id": "18ce54d4x5t"
    }
  },
  "data": {
    "bid_type": "MAX",
    "advertiser_user_id": 756201191646691328,
    "name": "Untitled",
    "placements": [
      "ALL_ON_TWITTER"
    ],
    "start_time": null,
    "bid_amount_local_micro": 5000000,
    "automatically_select_bid": false,
    "advertiser_domain": null,
    "target_cpa_local_micro": null,
    "primary_web_event_tag": null,
    "charge_by": "ENGAGEMENT",
    "product_type": "PROMOTED_TWEETS",
    "end_time": null,
    "bid_unit": "ENGAGEMENT",
    "total_budget_amount_local_micro": null,
    "objective": "TWEET_ENGAGEMENTS",
    "id": "aq4uw",
    "entity_status": "ACTIVE",
    "account_id": "18ce54d4x5t",
    "optimization": "DEFAULT",
    "categories": [],
    "currency": "USD",
    "created_at": "2017-12-21T07:14:58Z",
    "tracking_tags": [],
    "updated_at": "2017-12-21T07:19:40Z",
    "include_sentiment": "POSITIVE_ONLY",
    "campaign_id": "a3mnn",
    "creative_source": "MANUAL",
    "deleted": false
  }
}

However, because I’m requesting data for 2017-12-15—before this line item was created—I see null values.

$ twurl -H ads-api.twitter.com "/2/stats/accounts/18ce54d4x5t?entity=LINE_ITEM&entity_ids=aq4uw&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER&start_time=2017-12-15&end_time=2017-12-16&granularity=TOTAL"
{
  "data_type": "stats",
  "time_series_length": 1,
  "data": [
    {
      "id": "aq4uw",
      "id_data": [
        {
          "segment": null,
          "metrics": {
            "impressions": null,
            "tweets_send": null,
            "qualified_impressions": null,
            "follows": null,
            "app_clicks": null,
            "retweets": null,
            "likes": null,
            "engagements": null,
            "clicks": null,
            "card_engagements": null,
            "poll_card_vote": null,
            "replies": null,
            "url_clicks": null,
            "carousel_swipes": null
          }
        }
      ]
    }
  ],
  "request": {
    "params": {
      "start_time": "2017-12-15T08:00:00Z",
      "segmentation_type": null,
      "entity_ids": [
        "aq4uw"
      ],
      "end_time": "2017-12-16T08:00:00Z",
      "country": null,
      "placement": "ALL_ON_TWITTER",
      "granularity": "TOTAL",
      "entity": "LINE_ITEM",
      "platform": null,
      "metric_groups": [
        "ENGAGEMENT"
      ]
    }
  }
}

On ads.twitter.com, you’ll see 0s instead of nulls. See this thread for more information on that in case that is causing confusion.

If there is some other issue, please let us know.

Thanks!