Using the twitter-python-ads-sdk (https://github.com/twitterdev/twitter-python-ads-sdk), I’m attempting to asynchronously retrieve PROMOTED_TWEET data by first querying the POST stats/jobs/accounts/:account_id endpoint to retrieve job_ids, and then the GET stats/jobs/accounts/:account_id endpoint to download the gzip data. When making the POST request, I am passing in >1 entity_ids and >1 metric_groups, but am only receiving back a job_id for 1 entity_id and 1 metric_group. For example, the code looks like this…
from twitter_ads.http import Request
from twitter_ads.client import Client
client = Client(...)
account_id = '18ce54o6agw'
params = {
'start_time': '2018-10-01T04:00:00Z',
'end_time': '2018-10-07T04:00:00Z',
'entity': 'PROMOTED_TWEET',
'entity_ids': ['1urqsy', '26jsvt'],
'granularity': 'DAY',
'metric_groups': ['BILLING', 'ENGAGEMENT'],
'placement': 'ALL_ON_TWITTER'
}
resource = '/4/stats/jobs/accounts/{account_id}'.format(account_id=account_id)
response = Request(client, 'post', resource, params=params).perform()
Then, response.body only returns the following (notice it is only for the first entity_id and the first metric_group):
{'request': {'params': {'start_time': '2018-10-01T04:00:00Z',
'entity_ids': ['1urqsy'],
'end_time': '2018-10-07T04:00:00Z',
'placement': 'ALL_ON_TWITTER',
'granularity': 'DAY',
'entity': 'PROMOTED_TWEET',
'metric_groups': ['BILLING']}},
'data': {'start_time': '2018-10-01T04:00:00Z',
'segmentation_type': None,
'url': None,
'id_str': '1072523786702876672',
'entity_ids': ['1urqsy'],
'end_time': '2018-10-07T04:00:00Z',
'country': None,
'placement': 'ALL_ON_TWITTER',
'id': 1072523786702876672,
'expires_at': None,
'account_id': '18ce54o6agw',
'status': 'PROCESSING',
'granularity': 'DAY',
'entity': 'PROMOTED_TWEET',
'created_at': '2018-12-11T16:09:31Z',
'platform': None,
'updated_at': '2018-12-11T16:09:31Z',
'metric_groups': ['BILLING']}}
So the question is, how can I make the request with multiple entity_ids and multiple metric_groups, and receive back a list of job_ids?