Python SDK of Postmen API
Project description
Installation
Via pip
Run the following:
$ pip install postmen
Via source code
Download the code archive, unzip it, create/activate virtualenv, go to the source root directory, then run:
$ python setup.py install
Usage
Quick Start
The following code list all labels for API key.
import postmen
try:
api = postmen.API('API_KEY', 'sandbox')
labels = api.get('labels')
except PostmenError, e:
print('Error: %s' % e)
Get API object
Import postmen module and obtain API object. Pass valid API key and region (sandbox, us-west, ap-southeast).
import postmen
api = postmen.API('API_KEY', 'REGION')
Find detailed description in API class documentation.
Make API calls
Common method to make API call (normally you shouldn’t use it directly):
.call(method, path, payload)
HTTP-methods access to directly map API docs to SDK calls:
.GET(path)
.POST(path, payload)
User-friendly API access methods:
.get(resource, [id]): get all resources (e.g. list all labels) or specific resource if id is specified (e.g. retrieve a label)
.create(resource, payload): create a new resource (e.g. create label)
.cancel(resource, id): delete/cancel a resource (e.g. cancel a label)
path, resource, id are strings.
payload is JSON string or dict/list.
All methods accept optional arguments for .call(). Find detailed description in API.call() documentation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.