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:
Apipheny is a free API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to API data sources, easily.
1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install
2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.
In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.
Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new
1. In your Mailchimp account, click the arrow next to your account icon and select the Account option:
2. On the next page, in the menu, click Extras and then click API keys:
3. Next scroll down to the Your API keys section and click Create A Key:
4. Your API key should have been generated:
5. Enter a descriptive name for your API key by editing the Label field, so you know what application is using that key:
Finally, copy and paste your Mailchimp API key somewhere safe, as you will need it in the next steps.
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:
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):
For endpoints that accept parameters, the documentation is where you would find them listed and explained, along with example inputs and responses.
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:
https://us4.api.mailchimp.com/3.0/list
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, but replace your_api_key with the value you generated previously, in Step 2. There should be a space between “Basic” and “your_api_key” (see screenshot).
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:
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.
Schedule requests for automatic updates
Reference cell values in requests
Stack multiple URLs in a single request
Crypto API Tutorials: