Skip to main content

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):

  1. .call(method, path, payload)

HTTP-methods access to directly map API docs to SDK calls:

  1. .GET(path)

  2. .POST(path, payload)

User-friendly API access methods:

  1. .get(resource, [id]): get all resources (e.g. list all labels) or specific resource if id is specified (e.g. retrieve a label)

  2. .create(resource, payload): create a new resource (e.g. create label)

  3. .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.

Source Distribution

postmen-0.4.tar.gz (7.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page