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

Usage

This can be used as a drop-in replacement for mailchimp3 – just change the import at the top, and everything should work the same:

from batch_mailchimp import BatchMailChimp as MailChimp

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

The additional functionality comes when we initialise the client with batch=True:

from batch_mailchimp import BatchMailChimp as MailChimp

batch_client = MailChimp(
    mc_api='YOUR_API_KEY',
    mc_user='YOUR_USERNAME',
    batch=True)

If we do this, operations are stored up in the client, to be run later. For example:

# add John Doe with email john.doe@example.com to list matching id '123456'
batch_client.lists.members.create(
    '123456', {
        'email_address': 'john.doe@example.com',
        'status': 'subscribed',
        'merge_fields': {
            'FNAME': 'John',
            'LNAME': 'Doe',
        },
    },
)

All new operations will be added to the batch. When we’re ready, we can run all the operations in the batch:

batch = batch_client.run_batch()

We can check the batch’s status using:

batch.status()

API Structure and Endpoints

The API structure and endpoints match that of mailchimp3. You should refer to their documentation for usage.

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.9.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file batch-mailchimp-0.0.9.tar.gz.

File metadata

  • Download URL: batch-mailchimp-0.0.9.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.0

File hashes

Hashes for batch-mailchimp-0.0.9.tar.gz
Algorithm Hash digest
SHA256 b36f7565e83d9dbfbfd3be8e002a64ea03645c6f51711451bc021ee9e2588768
MD5 d5a217d9243c98afa6fbc1ed8647d364
BLAKE2b-256 7e0a059eba72c897151414abf26b31f965ceda1cef836ab9dcd0a9ed9ba0e01a

See more details on using hashes here.

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