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:

  1. Install the Apipheny Add-on
  2. Register a Constant Contact application
  3. Generate an Authorization Code
  4. Generate an Access Token
  5. Choose a Constant Contact Endpoint
  6. Enter your Constant Contact API request into Apipheny
  7. Run the Constant Contact API request in your Google Sheet

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

Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.

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.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

Step 2.) Register a Constant Contact application

After you’ve logged in to your Constant Contact account, on the My Applications section of the developer portal, click the Register link:

In the Constant Contact developer portal, click My Applications > Register
In the Constant Contact developer portal, click My Applications > Register

The New Application overlay dialog will then be displayed.

Enter a name for your application then click the Save button:

Enter any name for your App and click Save
Enter any name for your App and click Save

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:

Copy and paste your API Key to a safe location, then click the Generate Secret button
Copy and paste your API Key to a safe location, then click the Generate Secret button

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:

Click Generate Secret
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:

Copy and paste your App Secret to a safe location because you will need it again later
Copy and paste your App Secret to a safe location because you will need it again later

Step 3.) Generate an Authorization Code

In your browser address bar, copy and paste the following link:

https://api.cc.email/v3/idfed?client_id=your_client_ID&redirect_uri=your_redirect URI&response_type=code&scope=contact_data+campaign_data+account_read+account_update

! Don’t forget to replace the following values/parameters:

  • your_client_ID with your API key, obtained when you created the app;
  • your_redirect_URI with the redirect URI you have in your app settings (by default, the redirect URI is https://localhost, but you can change it anytime)

After you replace the two values and press Enter, an authorization window will be displayed. Click Allow to grant access:

Click Allow in the authorization window
Click Allow in the authorization window

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!

Copy and paste your authorization code to a safe location
Copy and paste your authorization code to a safe location

Step 4.) Generate an Access Token

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:

  • Base64_encoded_value is the value obtained by Base64-encoding the following string: “your_API_Key:your_client_secret”. Don’t forget to replace the your_API_Key and your_client_secret fields with their actual values and keep the “:” sign between them, without any spaces. You can use a website such as https://www.base64encode.org/ for the base64 encoding
  • your_authorization_code is the code you previously obtained, in Step 3
  • your_redirect_URI is your redirect URI that you previously configured in your Account Settings
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).
Generating a Constant Contact access token
Generating a Constant Contact access token

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.

Note: If the token/key that you generate has an expiration time, you will need to complete this same process again to get a new token when the old one expires.

Step 5.) Choose a Constant Contact Endpoint URL

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:

Constant Contact API documentation
Constant Contact API documentation

For example, when clicking the Contacts category, the page scrolls to an introduction section and a list of 7 endpoints:

  • GET Contacts Collection
  • POST (create) a contact
  • GET a collection of V2 and V3 API contact IDs
  • Create or Update a Contact
  • Delete a Contact
  • Get a Contact
  • PUT (update) a Contact
Constant Contact endpoint documentation example
Constant Contact endpoint documentation example

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):

https://api.cc.email/v3/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:

Constant Contact API documentation
Constant Contact API documentation – Response Sample

All API calls to Constant Contact should be made to this base URL:

https://api.cc.email/v3

All endpoints are appended to that base URL.

Note: Check their documentation to confirm the latest version and update the version number in the URL if necessary.

Step 6.) Enter your Constant Contact API request into Apipheny

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:

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 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:

https://api.cc.email/v3/account/emails

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. There should be a space between the word 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:

Constant Contact API request entered into the Apipheny add-on in Google Sheets
Constant Contact API request entered into the Apipheny add-on in Google Sheets

Step 7.) Run the Constant Contact API request in your Google Sheet

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:

Constant Contact integrated with Google Sheets
Constant Contact integrated with Google Sheets

That’s it! You’ve successfully connected your Constant Contact account to Google Sheets using the Constant Contact API, Google Sheets API, and the Apipheny add-on.

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.


API Tutorials



API Knowledge

What is an API?
What is an API URL?
What are parameters?
What is an endpoint?
What is an API key/token?
What is basic authentication?
What are headers?
What is a GET request?
What is a POST request?