A Meteor wrapper for the MailChimp API.
- node-mailchimp - A node.js wrapper for the MailChimp API
meteor-mailchimp exposes the following features of the MailChimp API to your Meteor application:
- MailChimp API v2.0
Further information on the MailChimp API and its features is available at https://github.com/gomfunkel/node-mailchimp.
meteor-mailchimp also exposes one template you can use out of the box: MailChimpListSubscribe
, which you can use to enable your visitors to subscribe to your mailing list(s).
Install using Meteorite - Installer & smart package manager for Meteor:
$ mrt add mailchimp
Use in your template:
<div id="subscribeForm">
{{> MailChimpListSubscribe}}
</div>
Put in your server's settings.json:
{
"MailChimpOptions": {
"apiKey": "<Your MailChimp API Key>",
"listId": "<ID of your default mailing list>"
}
}
and start your server with:
meteor --settings settings.json
or
mrt --settings settings.json
MailChimp takes two arguments. The first argument is your API key, which you can find in your MailChimp Account. The second argument is an options object which can contain the following option:
version
The API version to use. Defaults to 2.0.
All of the API categories and methods described in the MailChimp API v2.0 Documentation (http://apidocs.mailchimp.com/api/2.0) are available in this wrapper both on the server and the client. To use them the method call
is used which takes four parameters:
section
The section of the API method to call (e.g. 'campaigns').method
The method to call in the given section.params
Parameters to pass to the API method.callback
Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
Example:
try {
// You can as well pass different parameters on each call
var mailchimp = new MailChimp( /* apiKey, { version : '2.0' } */ );
mailchimp.call(
'campaigns',
'list',
{
start: 0,
limit: 25
},
function ( error, result ) {
if ( error ) {
console.log( error.message );
} else {
console.log( JSON.stringify( result ) ); // Do something with your data!
}
}
);
mailchimp.call(
'campaigns',
'template-content',
{
cid: '/* CAMPAIGN ID */'
},
function ( error, result ) {
if ( error ) {
console.log( error.message );
} else {
console.log( JSON.stringify( result ) ); // Do something with your data!
}
}
);
} catch ( error ) {
console.log( error.message );
}
- Fixed typo in README.md
- Updated README.md to reflect changes in v0.4.0
- Introduce settings.json for MailChimpOptions
- If already subscribed show different message then success message
- Enable submit with return key
- On client, MailChimp.call() now reads API Key from session variable 'MailChimpOptions.apiKey' as well
- Initial release
Copyright © 2014 Miroslav Hibler
meteor-mailchimp is licensed under the MIT license.