I am trying to use the createsend library in python to extract data from Campaign Monitor about a company's campaigns so I can upload it to their business intelligence tool (which does not have a connector developed of course...).
Warning: Not super familiar in python (R is home base for me)
So far, I've gotten my client list, as well as the list of their campaigns with the campaign ID so I can pull a particular one out.
from createsend import *
auth = {'api_key': 'company's API key'}
cs = CreateSend(auth)
clients = cs.clients()
campaign_ids = cs.clients()
for cl in clients:
print("Client: %s" % cl.Name)
client = Client(auth, cl.ClientID)
print("- Campaigns:")
for cm in client.campaigns():
print(" - %s" % cm.Subject)
print(" - %s" % cm.CampaignID)
campaign1 = Campaign(auth, 'campaign ID of interest')
print(campaign1.clicks)
This returns
<bound method Campaign.clicks of <createsend.campaign.Campaign object at 0x000001B04F405EC8>>
If I run print(campaign1.clicks())
This returns <class 'createsend.utils.CreateSendModel'>
How do I access the data that is inside of here? I have scoured the help file over the last 24 hours and really have no idea what I am doing wrong to access this data.
Thank you for reading!
Alright, for anyone encountering this in the future I hope I can save you some time. This was my solve:
Now I have an object with class "dict" that I can convert into a .csv and upload the data wherever I want it.
The ._get line was hidden inside the "summary()" function...I'm not sure if this is a bug or working as intended, but it was extremely difficult to figure out from the documentation.
Good luck if you find this and I hope it saves you some time!