Python API analytics giving None values


I used the following code in Python

ACCOUNT_ID = '1887vp'

account = client.accounts(id=ACCOUNT_ID)
campaign = account.campaigns().next()
line_item = account.line_items(None,

for line_item in account.line_items():

This should give me the engagement stats for all line items within this account.
While i can see the line item names and ids just fine, when i try to get the engagement stats, i get all engagement stats as None for every line item in this account.

Could someone please tell me what did i miss here?



Please provide the campaign ID you’re requesting data for.

Also, please keep these type of questions here and not on GitHub.


there is a list of campaigns that i am trying to get the metrics for promoted tweets within them for. An example campaign id would be ‘bjffo’

How would i get the promoted tweets within this campaign using a synchronous call. I cannot find a way to get the list of promoted tweets within a line item

Please help!


I took a look at the campaign you’re requesting data for. It has the following flight dates:

  • "start_time": "2018-10-08T17:11:25Z"
  • "end_time": "2018-10-15T06:59:00Z"

It looks like you tried pulling stats on 2018-10-08 (based on the time of your original post). Since the campaign had likely not started, it’s expected to see no data. We represent that as null values in the API response. (In Python, these would be represented as None values.) See this post.

Answered here.


Thanks. i managed to get it working with the help of your code. Appreciate the rapid responses