mailchimp-api-v31.13.0 • Public • Published
Mailchimp api wrapper for v3 of the mailchimp api, with batch handling. Supports both promise and callback handling.
var Mailchimp =var mailchimp = api_key;//Callback stylemailchimp//Promise stylemailchimp
seamless batch calls, with polling and unpacking of results
//Callback stylemailchimp//Promise stylemailchimp
Version 3 of the mailchimp api is an excellent RESTful api. This library makes it easy to integrate mailchimp using their own api documentation.
This library also supports easy usage of the mailchimp batch operations, enabling them to be used just as the standard api calls.
$ npm install mailchimp-api-v3
For information on the possible calls, refer to the mailchimp api v3 documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/overview/
In all calls you can omit the callback, and a promise will be returned instead.
var Mailchimp =var mailchimp = api_key;
path can be given either exactly as in the mailchimp documentation (
path_params specifying id values, or as a string with path parameters already substituted, and no
For each request method, convenience calls exists to make common calls:
This allows shorthand forms like:
var calls =method : 'post'path : '/lists/id1/members'body :email_address : 'firstname.lastname@example.org'status : 'subscribed'method : 'post'path : '/lists/id1/members'body :email_address : 'email@example.com'status : 'subscribed'mailchimp
batch takes an array of call options, exactly as used in the standard call.
waitwhether or not to wait for the batch command to finish, defaults to
waitis true, the interval to poll for the status of the batch call, defaults to 2000ms
waitis true, whether or not to get and unpack the results of the batch operation, and return the response bodies.
waitis true, whether or not to log progress to the console
If you call
wait : false, you can use the returned batch id to resume pooling and unpacking the results at a later time.
This also allows you to "reconnect" to a batch operation after a crash or similar.
Single operation batch
If you pass a single operation, instead of an array to
batch, the result will be the same as if you ran the operation without batch.
This is very useful if you want to make calls without paging, where a normal call would take to long, and likely time out.