Skip to content

Instantly share code, notes, and snippets.

@jbender
Created April 5, 2016 17:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbender/47d168ca7993c00edbdf6242456fa594 to your computer and use it in GitHub Desktop.
Save jbender/47d168ca7993c00edbdf6242456fa594 to your computer and use it in GitHub Desktop.
Getting Started with Contactually API v2 - Python
import requests
client = http.client.HTTPSConnection('api.contactually.com')
host = 'https://api.contactually.com'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN_HERE'
}
response = requests.get(host + '/v2/me', headers=headers)
print(response.json())
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