Python client for ONTRAPORT API. http://ontraport.com/ http://ontraport.com/partners-api/
Important! This project is work in progress, probably with full of bugs and limited feature set. Any kind of contribution is welcomed.
import ontraport
ontraport.config.app_id = <YOUR APP ID>
ontraport.config.api_key = <YOUR API KEY>
Make sure the API Key has the needed permissions and the owner is set. More info: https://support.ontraport.com/entries/26073705-Contacts-API#auth
Create contact:
contact = ontraport.Contact.create(
first_name="John",
last_name="Doe",
email="[email protected]",
tags=["MyApp users"]
)
Retrieve contact:
contact = ontraport.Contact.retrieve(id=1)
print contact.email
Delete contact:
c = ontraport.Contact(id=1)
c.delete()
Fetch sequences:
>>> ontraport.Contact.fetch_sequences()
[('1', 'my sequence 1'), ('2', 'my sequence 2'), ('3', 'my sequence 3')]
Add sequences:
>>> contact_id = 100
>>> contact = ontraport.Contact(id=contact_id)
>>> contact.add_sequences([1, 2])
Remove sequences:
>>> contact_id = 100
>>> contact = ontraport.Contact.retrieve(contact_id)
>>> contact.remove_sequences([1, 2])
Pull tags:
>>> contact = ontraport.Contact.pull_tags()
[('1', 'my tag 1'), ('2', 'my tag 2'), ('3', 'my tag 3')]
Fetch tags:
>>> contact = ontraport.Contact.fetch_tags()
['my tag 1', 'my tag 2', 'my tag 3']
Add tags:
>>> contact_id = 100
>>> contact = ontraport.Contact(id=contact_id)
>>> contact.add_tags(['my tag1', 'my tag 2'])
Remove tags:
>>> contact_id = 100
>>> contact = ontraport.Contact(id=contact_id)
>>> contact.remove_tags(['my tag 2'])