Im currently using this python package in order to query campaign data such as impressions, clicks, costs, etc. but everytime the JSON has ‘data’:[]
Here is a copy of the code:
import time
import pprint as pp
from twitter_ads.client import Client
from twitter_ads.campaign import LineItem
from twitter_ads.enum import METRIC_GROUP
CONSUMER_KEY = 'xxxxxx'
CONSUMER_SECRET = 'xxxxxx'
ACCESS_TOKEN = 'xxx-xxxxxx'
ACCESS_TOKEN_SECRET = 'xxxxxxxx'
ACCOUNT_ID = 'xxxxxxxx'
# initialize the client
client = Client(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
# load the advertiser account instance
account = client.accounts(ACCOUNT_ID)
# limit request count and grab the first 10 line items from Cursor
campanias = list(account.campaigns())[:20]
# the list of metrics we want to fetch, for a full list of possible metrics
# see: https://dev.twitter.com/ads/analytics/metrics-and-segmentation
metric_groups = ['ENGAGEMENT','BILLING']
# fetching stats on the instance
campanias[0].stats(metric_groups)
# fetching stats for multiple line items
ids = map(lambda x: x.id, campanias)
LineItem.all_stats(account, ids, metric_groups)
# fetching async stats on the instance
queued_job = LineItem.queue_async_stats_job(account, ids, metric_groups)
# get the job_id:
job_id = queued_job['id']
# let the job complete
seconds = 15
time.sleep(seconds)
async_stats_job_result = LineItem.async_stats_job_result(account, job_id)
async_data = LineItem.async_stats_job_data(account, async_stats_job_result['url'])
pp.pprint(async_data)
Manually i can see the account actually had activity on campaigns.
Any idea what i could be doing wrong?