Constant Contact is a popular email marketing software.
In this tutorial, I’ll show you how to connect the Constant Contact REST API to Google Sheets in 7 steps:
To pull data from the Constant Contact API to Google Sheets without writing any code, first install and open the Apipheny Google Sheets add-on.
Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited API data sources, save API requests, schedule API requests, and more. Click here for more info about Apipheny.
1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the page: https://gsuite.google.com/marketplace/app/apipheny/966163326746
2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons option in the top menu. In the add-ons menu, you should see Apipheny.
In the menu at the top of your Google Sheet, click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets, like this:
The New Application overlay dialog will then be displayed.
Enter a name for your application then click the Save button:
You’ll then be redirected to the App details page. Copy and paste your API Key to a safe location, because you’ll need it again later. Then click the Generate Secret button to display the client secret:
A disclaimer box will be shown, letting you know you’ll have to update your code to use the new secret, if a client secret was previously created for your app. Click Cancel if you do not want to generate a new secret, or click Generate Secret:
The App Secret overlay dialog will be displayed. Copy and paste the secret value to safe location, because you’ll need it in the next steps:
In your browser address bar, copy and paste the following link:
! Don’t forget to replace the following values/parameters:
After you replace the two values and press Enter, an authorization window will be displayed. Click Allow to grant access:
The authorization code will then be displayed in your browser’s address bar. Copy and paste the value of your authorization code to a safe location and proceed with the following step, as this code is only valid for 60 seconds!
To generate an access token, open up a command prompt window (for Windows OS) or a terminal (for Mac OS) and compose the following curl command:
curl -X POST -i -H "application/x-www-form-urlencoded" -H "authorization: Basic Base64_encoded_value" "https://idfed.constantcontact.com/as/token.oauth2?code=your_authorization_code&redirect_uri=your_redirect_URI&grant_type=authorization_code"
You’ll need to replace a few values:
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).
Your access token will be displayed in the response. Copy and paste the value to a safe location, because you’ll need it in the next steps.
In this section, we’ll show you how to browse the Constant ContactAPI documentation to find the API endpoint URL that retrieves the information you need from your Constant Contact account. Every API has a URL, and every URL has an endpoint which is the last part of the URL that tells the API what data to return back to you.
If you already know your URL and endpoint, or you want to use the same example as us, just skip to Step 6.
To look through available endpoints, first open the Constant Contact API documentation page: https://v3.developer.constantcontact.com/api_reference/index.html#!/Account_Services/retrieveEmailAddresses
The menu on the left contains the Base URL for this API and the API Reference section. In the API Reference section, you can find a list of categories, each with its own endpoints.
Clicking on a category such as Account Services will scroll to that category’s section and show you a list of the associated endpoints:
For example, when clicking the Contacts category, the page scrolls to an introduction section and a list of 7 endpoints:
If you want to check whether certain data is available via the Constant Contact API, the API documentation is where you go to find all the available endpoints that you can query.
Another example endpoint is GET Contacts Collection, and this is what the whole API URL looks like put together, include the base URL (https://api.cc.email/v3) and endpoint (/contacts):
Each endpoint’s documentation contains descriptions of the endpoint’s purpose, the available parameters, response messages, and an option to make a test request to the endpoint. On a separate column on the right, you can find the CURL response to the endpoint:
All API calls to Constant Contact should be made to this base URL:
All endpoints are appended to that base URL.
Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab. With the Import tab open, enter these details into the add-on:
API URL: In Step 5, we explained how you can find the Constant Contact REST API endpoint that you need. Now copy and paste your complete Constant Contact API URL into the Apipheny add-on, where it says API URL Path, followed by any parameters required for your query (if applicable).
For this example, we are using the /account/emails endpoint that returns a collection of email addresses for the account associated with your access token. This is what the whole URL looks like:
If you’re following the same example as us, you can copy and paste this URL into Apipheny, where it says “API URL”.
Headers: In the Headers section of Apipheny, add two rows with the following keys and values:
Header 1 Key: Authorization Value: Bearer your_token Header 2 Key: Content-Type Value: Application/json
Where it says your_ token, copy and paste your actual token that you got in Step 4. Don’t forget to put the word “Bearer” before your token. There should be a space between “Bearer” and your_ token.
Here’s what your API request should look like when entered into Apipheny, if you’re following the same example as us or using a similar endpoint:
Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the Constant Contact API data to be imported into your Google Sheet. Here’s what our request looked like when completed:
After making a successful request to the Constant Contact API, try querying a different Constant Contact API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:
Learn more about APIs: