How to pull data from the Mailchimp API into Google Sheets

Mailchimp is a a popular email marketing platform. With Mailchimp’s API, you can get data on your campaigns, ads, lists and audiences, reporting, and much more.

In this tutorial, I’ll show you step-by-step how to connect the Mailchimp API to Google Sheets in 5 steps:

  1. Install the Apipheny Add-on
  2. Get a Mailchimp API Key
  3. Choose your Endpoint URL
  4. Enter your Mailchimp API request into Apipheny
  5. Run the Mailchimp API request in your Google Sheet

Step 1.) Install and open the Apipheny add-on in Google Sheets

To pull data from Mailchimp into Google Sheets, first install and open the Apipheny Google Sheets add-on.

Apipheny is an API integrator for Google Sheets that you can use to connect to unlimited API data sources, make unlimited API requests, and more. Click here to learn more about Apipheny. There’s a 30-day free trial included then it’s $19-$29/month.

1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the next page: https://gsuite.google.com/marketplace/app/apipheny/966163326746

Install Apipheny
Install Apipheny

2. After you’ve installed Apipheny, open a Google Sheet and then click on Add-Ons in the top menu. Then, in the add-ons menu, you should see Apipheny. Just click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets:

Open Apipheny
Open Apipheny

Step 2.) Get a Mailchimp API Key

1. In your Mailchimp account, click the arrow next to your account icon and select the Account option:

Log in to Mailchimp and click Account
Log in to Mailchimp and click Account

2. On the next page, in the menu, click Extras and then click API keys:

Click Extras > API keys
Click Extras > API keys

3. Next scroll down to the Your API keys section and click Create A Key:

Your API keys > Create a Key
Your API keys > Create a Key

4. Your API key should have been generated:

Mailchimp API key
Mailchimp API key

5. Enter a descriptive name for your API key by editing the Label field, so you know what application is using that key:

Enter a label/name for your API key
Enter a label/name for your API key

Finally, copy and paste your Mailchimp API key somewhere safe, as you will need it in the next steps.

Step 3.) Choose a Mailchimp API Endpoint

In this section, we’ll show you how to browse the Mailchimp API documentation to create an API URL that retrieves the specific information you need from your Mailchimp account.

If you already know your Mailchimp API URL, or you want to use the same example URL as us, just skip to Step 4.

First, open the Mailchimp API documentation page: https://mailchimp.com/developer/reference/

The menu on the left contains a list of the available APIs, each with its own endpoints:

Mailchimp API documentation
Mailchimp API documentation

Clicking on an API scrolls to that API’s section, containing a list of associated endpoints. For instance, if you click the Campaigns API, the page will scroll to the list of its 3 endpoints: Content, Feedback, and Send Checklist.

All API calls to Mailchimp should be made to the root domain:

Mailchimp API base URL:
https://<dc>.api.mailchimp.com/3.0/

One of the available endpoints is Content. If we use the Content endpoint, then our whole URL will look like this:

https://<dc>.api.mailchimp.com/3.0/campaigns/{campaign_id}/content

The <dc> part of the URL corresponds to the data center for your account. For example, if the last part of your Mailchimp API key is us4, all API endpoints for your account are available at https://us4.api.mailchimp.com/3.0/

Each endpoint’s documentation contains a short description, the HTTP method used (eg. GET) and the link you should append to the root API URL for querying this endpoint (eg. /contacts/v1/lists):

Mailchimp Content API documentation
Mailchimp “Content” API documentation

For endpoints that accept parameters, the documentation is where you would find them listed and explained, along with example inputs and responses.

Step 4.) Enter your Mailchimp API URL into Apipheny

Now you’re ready to enter your API request into your Google Sheet. Go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab (screenshot below).

With the Import tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) required by your API endpoint. For this example, we are using the GET method.

API URL: In Step 3, we explained how you can find the Mailchimp REST API endpoint that you need and how to put your whole URL together. Now copy and paste your complete Mailchimp API URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query (if applicable).

For this example, we are using the Lists API endpoint, to get all lists from our account:

Example Mailchimp API URL:
https://us4.api.mailchimp.com/3.0/lists

Headers: In the Headers section in Apipheny, you’ll need one row with the following key and value:

Key:
Authorization
Value:
Basic <your_api_key>

Just copy and paste the key and value into Apipheny.

your_api_key is the value you generated previously, in Step 2. There should be a space between “Basic” and “your_api_key” (see screenshot).

Mailchimp API request in Apipheny
Mailchimp API request in Apipheny

Step 5.) Run the Mailchimp API Request in your Google Sheet

Your last step is to click the Run button at the bottom of the Apipheny add-on and wait for the Mailchimp API data to be imported into your Google Sheet, like this:

Mailchimp API data in Google Sheets
Mailchimp API data in Google Sheets

After making a successful request to the Mailchimp API, try querying a different endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:

  • Save and schedule your API request
  • Make a POST request (if available)
  • Run multiple API URLs in the same request
  • Use the custom =APIPHENY() function to call the API request inside your spreadsheet
  • Create an API request by referencing the value of a cell in the API URL with three curly braces eg. {{{Sheet1!A1}}}

Related articles:

Related Posts

Leave a Comment