A node.js wrapper for MailChimp's Mandrill API.

Downloads in past


13461.0.110 years ago11 years agoMinified + gzip package size for node-mandrill in KB


node-mandrill is a node.js module designed to allow you to access MailChimp's Mandrill API with minimal overhead.
I designed node-mandrill so the only documentation you need, in addition to the Mandrill API specification, is how to install and install the module, and how to make a call.


Until I submit to npm, you'll want to follow these directions:
cd ~/.node_modules
git clone git:// mandrill


Usage is super simple. To require the mandrill library and initialize it with your account API key:
var mandrill = require('mandrill')('<Your Api Key Here>');
To make a call to the API, call the mandrill function. For example:
//send an e-mail to jim rubenstein
mandrill('/messages/send', {
    message: {
        to: [{email: '', name: 'Jim Rubenstein'}],
        from: '',
        subject: "Hey, what's up?",
        text: "Hello, I sent this message using mandrill."
}, function(error, response)
    //uh oh, there was an error
    if (error) console.log( JSON.stringify(error) );

    //everything's good, lets see what mandrill said
    else console.log(response);


mandrill(string: api-endpoint, object: options, function: callback)
string: api-endpiont, function: callback)
Api Endpoint: The REST url for the API you want to access. By default, all requests are made requesting JSON as the response format. If you'd like to utilize a different format, you cann append .yaml, .php, or .xml to the endpoint uri. Node-mandrill will parse json responses and pass them to the callback, but the other formats will be passed back as a string.
Options: A javascript object defining the options as needed for the requested API endpoint. note: your API key is not required here, as the module will automatically append it to your request. However, you can override your configured key by passing a value for a new key, using the key index of the options object.
Callback: A function reference for a function to call upon completion of the request. It should accept 2 arguments.
error: if an error occurred (either with the HTTP request, or within the Mandrill API) the error will be passed back in this argument. If there was no error, the value of error will be null.
response: the response from Mandrill in the requested format. JSON is requested by default, and is parsed into a native javascript object upon completion of the request. If you choose to use one of the other formats (xml, yaml, php) the response will be passed back as a string to be used with your favorite parsers.


  • A Mandrill account w/API key.
  • node.js v0.8.2+ (0.8.2 is the version I used to develop this module. I'm
unsure if it will work with previous ones. If you run a previous version, and it works, let me know and i'll update this)

Question? Problems?

If you run into problems, have questions, or whatever else you can open an issue on this repository, or tweet me @jimrubenstein. If you'd like to submit a patch, shoot me a pull request. I'd like to keep this module simple, so if you want to add all kinds of crazy functionality - you might want to fork. When in doubt, send a pull request - the worst that can happen is that I won't merge it (: