A Ruby API client for v2 of the MailChimp API. Please note that we generate this client/wrapper, so while we're happy to look at any pull requests, ultimately we can't technically accept them. We will, however comment on any additions or changes made due to them before closing them.


This can be installed via our gem using:

$ gem install mailchimp-api

Then you'll need to require 'mailchimp' in your code.

Alternatively, if you're using a recent version of Bundler, you can add the following to your Gemfile:

gem 'mailchimp-api', require: 'mailchimp'

Then bundle install and you're all set.

A basic example app to help kickstart you which - will also automatically install this package - is over in a public github repo

Make the following constants, in your environment file or where ever you are mentioning the constants.

MAILCHIMP-API-KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxx"

You can have a look here (mailchimp documentation), how you can get the API-KEY.

Now there are multiple things that you can do from mailchimp-api. I am mentioning the basic's that used commonly.

Now create the List at mailchimp and get the listId.

Add it in your constants, where you mentioned the API-KEY.

MAILCHIMP-LIST-ID = "xxxxxxxxxx"

Now the time is to get to know how to use mailchimp-api gem


Following line will create the object of mailchimp, we will access the mailchimp-api method using this object.

mailchimp =

Use cases that we will be using are listed below.

  1. Fetch All Members
  2. Get Members Info
  3. Get All Lists
  4. Subscribe Single User
  5. Subscribe Members in Batch
  6. Get All Campaigns

Fetch All Members


Get Members Info

emails = [{
            "email" => {
                         "email" => "",
                         "euid"  => "275",
                         "leid"  => "27546289917a6"

mc.lists.member_info(MAILCHIMP-LIST-ID, emails)

for further information of this method you can have look here

Get All Lists

  lists = mailchimp.lists.list
  list  = lists['data']

Subscribe Single User

                   { "email" => "",
                     "euid" => "123",
                     "leid" => "123123"

for further information of this method you can have look here

Batch Subscribe

Example for this method is not even given in mailchimp-api sample project.

In order to do bulk upload of subscribers. MailchimpApi provides you a method using which you can simply pass the hash of data and in single call all of your subscribers will be added at mailchimp.

Hash would be created in following format

subscribers = [{ "EMAIL" => { "email" =>,
                 "EUID" => "123",
                 "LEID" => "123123"

               :EMAIL_TYPE => 'html',
               :merge_vars => { "FIRSTNAME" => "Muhammad Awais",
                                "LASTNAME"  => "Muhammad Ilyas",
                                "STATUS"    => "Subscribed",
                                "LBOOKCNTRY" => "United States"

Now you can simply call the following method and it will do bulk upload at mailchimp.

mailchimp.lists.batch_subscribe(MAILCHIMP-LIST-ID, subscribers, false, true, false)

You can have look here(mailchimp api documentation) or here (ruby-docs)to get further information about batch-subscribe.

Get All Campaigns


You can also filtered the campaigns on there status as follow



This is documentation is for mailchimp-api 2.0.4


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request