Created
April 5, 2016 17:29
-
-
Save jbender/47d168ca7993c00edbdf6242456fa594 to your computer and use it in GitHub Desktop.
Getting Started with Contactually API v2 - Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
client = http.client.HTTPSConnection('api.contactually.com') | |
host = 'https://api.contactually.com' | |
headers = { | |
'Accept': 'application/json', | |
'Authorization': 'Bearer YOUR_TOKEN_HERE' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = requests.get(host + '/v2/me', headers=headers) | |
print(response.json()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contact_attributes = { | |
'first_name': 'Jonathan', | |
'last_name': 'Bender', | |
'email': 'jbender@contactually.com' | |
} | |
# Create the contact | |
contact = requests.post(host + '/v2/contacts', | |
data={ 'data': contact_attributes }, | |
headers=headers | |
).json()['data'] | |
# Get the available buckets | |
buckets = requests.get(host + '/v2/buckets', headers=headers).json()['data'] | |
# Add the bucket to the created contact | |
new_buckets = [{ id: buckets[0]['id'] }] | |
client.post("/v2/contacts/#{contact['id']}/buckets", | |
data={ data: new_buckets }, | |
headers=headers | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment