SiftScience/sift-python — pull request #1 by divad12 (2013-01-09 07:47:35+00:00)
Title: (For Doug, cc Fred) Python bindings for REST API, submitted to PyPI

This is based off https://github.com/SiftScience/code/commit/45458b63c7c0a710dcd9831ccb0f42f7ffe3592e and [our Ruby bindings](https://github.com/SiftScience/sift-ruby). These bindings are written using `requests`, the de-facto Python library for communicating with RESTful APIs. Further, this doesn't throw exceptions on HTTP errors, which was the biggest issue I had with the old Python client above.

Possible enhancements:
- non-blocking call to the API (is this possible?)
- wrap `requests` response object in a class
- tests
- more docs/examples
- license?

## Test plan
I'm using it live to track events on http://uwflow.com, but that was before the PyPI packaging.
I've tested the pip packaging with:

```
(pip_test_env) 23:29:14 Davids-Mac-mini @ [ sift-python ] (initial-commits) pip install sift
Downloading/unpacking sift
Downloading Sift-0.1.0.tar.gz
Running setup.py egg_info for package sift

warning: no files found matching '*.txt'
warning: no files found matching '*.txt' under directory 'docs'
Requirement already satisfied (use --upgrade to upgrade): requests>=0.14.1 in /Users/david/tmp/virtualenv-1.6.4/pip_test_env/lib/python2.7/site-packages (from sift)
Installing collected packages: sift
Running setup.py install for sift

warning: no files found matching '*.txt'
warning: no files found matching '*.txt' under directory 'docs'
Successfully installed sift
Cleaning up...
```

(the warnings can be cleaned up by removing the cruft in `manifest.in`)

and then:

```
(pip_test_env) 23:30:04 Davids-Mac-mini @ [ code ] python
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sift
>>> sift.Client

>>> a = sift.Client('api_key')
>>> a

>>> r = a.track('test', {'a': 2, 'test_property': 'blah blah', '$user_id': '5061a8db44957127ebf1bc9a'})
>>> r

>>> r.text
u'{"status": 0, "error_message": "OK", "time": 1357716729, "request": "{\\"a\\": 2, ...
```

and verified it updated on the Sift console.