Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PostMonkey 1.0b

PostMonkey is a simple Python (2.6+) wrapper for MailChimp’s API version 1.3.

Features

  1. 100% test coverage

  2. Connection handling via the excellent Requests library

  3. Configurable timeout

  4. Simple Exceptions

Installation

You can install postmonkey via easy_install:

easy_install postmonkey

Or by using pip (requires you to specify the version because latest is 1.0b):

pip install postmonkey==1.0b

Or by placing the requirement in install_requires in your setup.py file:

install_requires=[
    # all your other packages
    'postmonkey==1.0b',
]

Basic Usage

Once you create a PostMonkey instance with your MailChimp API key, you can use it to call MailChimp’s API methods directly:

from postmonkey import PostMonkey
pm = PostMonkey('your_api_key')
pm.ping() # returns u"Everything's Chimpy!"

If the MailChimp method call accepts parameters, you can supply them in the form of keyword arguments. See Examples for common use cases, and refer to the MailChimp API v1.3 official documentation for a complete list of method calls, parameters, and response objects.

MailChimp has established guidelines/limits for API usage, so please refer to their FAQ for information.

Note: it is the caller’s responsibility to supply valid method names and any required parameters. If MailChimp receives an invalid request, PostMonkey will raise a postmonkey.exceptions.MailChimpException containing the error code and message. See MailChimp API v1.3 - Exceptions for additional details.

Examples

Create a new PostMonkey instance with a 10 second timeout for requests:

from postmonkey import PostMonkey
pm = PostMonkey('your_api_key', timeout=10)

Get the IDs for your campaign lists:

lists = pm.lists()

# print the ID and name of each list
for list in lists['data']:
    print list['id'], list['name']

Subscribe “emailaddress” to list ID 5:

pm.listSubscribe(id=5, email_address="emailaddress")

Catch an exception returned by MailChimp (invalid list ID):

from postmonkey import MailChimpException
try:
    pm.listSubscribe(id=42, email_address="emailaddress")
except MailChimpException, e:
    print e.code  # 200
    print e.error # u'Invalid MailChimp List ID: 42'

Get campaign data for all “sent” campaigns:

campaigns = pm.campaigns(filters=[{'status': 'sent'}])

# print the name and count of emails sent for each campaign
for c in campaigns['data']:
    print c['title'], c['emails_sent']

Changelog

-Initial Release

-2012-10-11: Quote JSON string before sending POST request

-2013-07-03: Documentation updates and version bump (no code changes)

Release files for ak-postmonkey 1.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ak-postmonkey 1.0b1
File Size Uploaded
ak-postmonkey-1.0b1.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ak-postmonkey 1.0b1
File Interpreter ABI Platform
ak_postmonkey-1.0b1-py2-none-any.whl Python 2 none any Details

Total release size: 16.0 kB

Release files / ak-postmonkey-1.0b1.tar.gz

Download URL ak-postmonkey-1.0b1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c611af5e5ef396fa24cf55ba1f6353c059ecc4de320098084ad489d629c0ced5
BLAKE2b-256 checksum
How to use checksums
8af61f32bea049cc98c8e53e2796892d3c7ce062de6a8b727a8569cab9b9b2f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / ak_postmonkey-1.0b1-py2-none-any.whl

Download URL ak_postmonkey-1.0b1-py2-none-any.whl
Size 9.3 kB
Tags Python 2
SHA-256 checksum
How to use checksums
d9486fabc4bdac62b63d66dca36cd4f33f03c4015ac69c78c35c94e1deb1535e
BLAKE2b-256 checksum
How to use checksums
27c7ed3e6b33aba21b28cffa88a5f0a8bea9b5219b2e42500a9709d802013a5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0b1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page