Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


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 node, how to install the module, and how to make a call.


Using npm:

npm install node-mandrill

If you don't have or don't want to use npm:

cd ~/.node_modules
git clone git:// 


Usage is super simple. To require the mandrill library and initialize it with your account API key:

var mandrill = require('node-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_email: '',
        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])

mandrill(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)
  • request 2.9.100+
  • underscore 1.3.3+

Running Tests

Tests are written using Jasmine, using the jasmine-node binaries. You'll need to install jasmine-node to run the tests.

Once jasmine is installed, you will need to edit the spec/mandrill.spec.js file to reflect your Mandrill API key, and an email address to receive your test e-mail on. These two settings are at the top of the file. Once they're in place, run your tests by doing:

$ ./

On your command line. If you're running windows, well, sorry. ):

Question? Problems?

If you run into problems, have questions, or whatever else you can open an issue on this repository, or tweet me @jim_rubenstein. 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 (:


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







No releases published


No packages published