Skip to main content

A python client for v3 of MailChimp API, with batch support

Project description

A light wrapper around mailchimp3 that makes it easier to use batch operations.

Getting Started

Installation

pip install batch-mailchimp

Initialization

This can be used as a drop-in replacement for mailchimp3 – just change the import at the top:

from batch_mailchimp import BatchMailChimp as MailChimp

client = MailChimp(mc_api='YOUR_API_KEY', mc_user='YOUR_USERNAME')

Examples

You can use this exactly as you would the mailchimp3 library. The addition is the Batch class, for keeping track of batch operations. To use it, first create a new batch, then include it in an API call via the batch keyword argument.

from batch_mailchimp import Batch, BatchMailChimp as MailChimp

client = MailChimp(mc_api='YOUR_API_KEY', mc_user='YOUR_USERNAME')

# create a batch object...
my_batch = Batch()

# add John Doe with email john.doe@example.com to list matching id '123456'
client.lists.members.create('123456', {
        'email_address': 'john.doe@example.com',
        'status': 'subscribed',
        'merge_fields': {
            'FNAME': 'John',
            'LNAME': 'Doe',
        },
    },
    batch=my_batch,  # ...and include it in an API call.
)

The API call won’t fire immediately, but will instead be added to the batch. When you’re ready, run the batch:

my_batch.run()

You can check the status of your batch operation using:

my_batch.status()

You can also delete your batch operation using:

my_batch.delete()

API Structure and Endpoints

The API Structure matches that of mailchimp3. You should refer to their documentation for usage.

Endpoints are also the same, except for the edition of the batch keyword.

Support

If you are having issues, please create an issue or submit a pull request.

License

The project is licensed under the MIT License.

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

batch-mailchimp-0.0.1.tar.gz (3.2 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