Python client for Sailthru
Python
Latest commit 03259fc Jun 9, 2016 @peterzal peterzal upping version number
Permalink
Failed to load latest commit information.
examples bugzid:12180 removed tabs from code, changed exception handling to us… Mar 27, 2014
sailthru GET requests do not need to send data. Breaks some webservers. Jun 9, 2016
test update unit test Apr 1, 2016
.gitignore
CHANGES
MANIFEST.in adding manifest.in Jul 12, 2012
MIT-LICENSE
README.md
requirements.txt
setup.py upping version number Jun 9, 2016
tox.ini Added tests for python2.6 Jan 5, 2015

README.md

sailthru-python-client

For installation instructions, documentation, and examples please visit: http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/python

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

Python binding for Sailthru API based on Requests

It will make requests in JSON format.

Supports Python 2.6, 2.7, 3.3+

Installation (Tested with Python 2.7.x)

Installing with pip:

pip install sailthru-client

Running tests

Install tox and then type:

tox

API Rate Limiting

Here is an example how to check rate limiting and throttle API calls based on that. For more information about Rate Limiting, see Sailthru Documentation

sailthru_client = SailthruClient(api_key, api_secret)

# ... make some api calls ...

rate_limit_info = sailthru_client.get_last_rate_limit_info('user', 'POST')

# get_last_rate_limit_info returns None if given endpoint/method wasn't triggered previously
if rate_limit_info is not None:
    limit = rate_limit_info['limit'];
    remaining = rate_limit_info['remaining'];
    reset_timestamp = rate_limit_info['reset'];

    # throttle api calls based on last rate limit info
    if remaining <= 0:
         seconds_till_reset = reset_timestamp - time.time()
         # sleep or perform other business logic before next user api call
         time.sleep(seconds_till_reset);