Q:

MailChimp API | Python Shell | Get the list of user activity with openDate, clickDate and user email

I am very beginner with Python as well as with Mailchimp API, so I desperately need your advice. 
My ambition is to get the campaign report from the MailChimp that will contain the data in the format:
Email ----- email openDate ----- clicked (True/False) ----- clickDate
So far I was able to write the following code:

list_campaigns = client.campaigns.all(get_all=True)


for line in list_campaigns['campaigns']:
 campaign_list_name = line['recipients']['list_name']
 campaign_list_id = line['recipients']['list_id']
 print(campaign_list_id, campaign_list_name)

That provides me with the list of campaign and IDs. However, campaign-based reports are giving me general information on the campaign performance (e.g. number of users opened, number of clicks), and I was unable to get anything on a granular level.
Is it ever possible and if so, what might be the algorithm for the solution?
p.s. here's the library I've used for Python.
Thank you!

A:

Assuming you have a list of campaign_ids, the following prints the email addresses followed by a list of user activity which includes open and click timestamps:
from mailchimp3 import MailChimp
username = username
mykey = mykey
client = MailChimp(mc_api=mykey,mc_user=username)
for idx in campaign_ids:
    email_activity = client.reports.email_activity.all(campaign_id=idx,get_all=True)
    for email_address in email_activity['emails']:
        print(email_address['email_address']
        print(email_address['activity'])                          

