Skip to content

ahalife/sailthru-python-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sailthru-python-client

A simple client library to remotely access the Sailthru REST API as per http://docs.sailthru.com/api.

By default, it will make request in JSON format.

Tested with Python 2.6.x but should work also with >= 2.4.x

It can make requests to following API calls:

For usage examples, you can take a look at Ruby and PHP examples

Installation (Tested with Python 2.7.x)

pip install git+https://github.com/sailthru/sailthru-python-client.git#egg=sailthru-client

Running tests

nosetests -v

Examples

from sailthru import sailthru_client as sc

api_key = '*******'
api_secret = '*******'
sailthru_client = sc.SailthruClient(api_key, api_secret)
try:
    response = sailthru_client.get_email('eli@sailthru.com')
except urllib2.URLError as e:
    # handle exceptions
    print e
except urllib2.HTTPError as e:
    # handle exceptions
    print e

Making POST Request

request_data = {'email': 'praj@sailthru.com', 'verified': 1, 'vars': {'name': 'Prajwal Tuladhar', 'address': {'city': 'Jackson Heights', 'zip': 11372, 'state': 'NY'}}, 'twitter': 'infynyxx'}
response = sc.api_post('email', request_data)

Making GET Request

request_data = {'email': 'praj@sailthru.com'}
response = sc.api_get('email', request_data)

Making DELETE Request

request_data = {'template': 'My-unused template'}
response = sc.api_delete('template', request_data)

postbacks

# for authenticating verify postbacks
verify_params = {'action': 'verify', 'email': 'praj@sailthru.com', 'send_id': 'TE8EZ3-LmosnAgAA', 'sig': 'generated_signature'}
is_verified_postback = sailtrhu_client.recieve_verify_post(verify_params)

# for authenticating optout postbacks
optout_params = {'action': 'verify', 'email': 'praj@sailthru.com', 'sig': 'generated_signature'}
is_optout_postback = sailtrhu_client.recieve_optout_post(optout__params)

# for authenticating hardbounce postbacks
hardbounce_params = {'action': 'hardbounce', 'email': 'praj@sailthru.com', 'sig': 'generated_signature'}
is_hardbounce_postback = sailtrhu_client.recieve_hardbounce_post(hardbounce_params)

About

Python client for Sailthru

Resources

License

Stars

Watchers

Forks

Packages

No packages published