How to import data from Pinterest into Google Sheets

Pinterest is a social network that allows users to visually share and discover new interests.  We can use the Pinterest API to import data from Pinterest into Google Sheets. In this tutorial, we’ll show you how to connect the Pinterest REST API to Google Sheets in 6 steps:

  1. Install the Apipheny add-on
  2. Create a Pinterest API app
  3. Obtain an access token
  4. Choose an endpoint
  5. Enter your Pinterest API request into Apipheny
  6. Run the Pinterest 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.) Create an app

After logging into your Pinterest Business account, go to https://developers.pinterest.com/apps/ and connect an application by clicking the Connect app button:

My Apps section
My Apps section

Complete all the fields that appear on the screen:

Connect App section
Connect App section
Required fields
Required fields
Another required fields
More required fields

Mark the I’m not a robot checkbox, then click the Submit button:

Submit the app step
Submit the app step

After creating the app, your trial access will be in the Pending status. To become Active (as shown in the picture below) you may need to wait a couple of days. After the status is Active you can proceed with the next steps.

Application status
Application status

After your app has been approved, in the Configure tab you will find your App id and App secret key:

The Configure tab
The Configure tab

Copy these values to a safe location because you will need them later.

Step 3.) Obtain an access token

In your browser’s URL bar, paste the following link and then press Enter:

https://www.pinterest.com/oauth/?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&scope=boards:read,pins:read,ads:write,boards:writepins:write,user_accounts:read&state=abc
  • Make sure to replace CLIENT_ID and REDIRECT_URL with the real values that you obtained in the previous step
  • Don’t forget to add the scopes you need at the scope parameter

When you visit the URL, an Authorization page will then be displayed. Click the Give access button to continue:

Authorize app page
Authorize app page

The browser will then navigate to the redirect URL that you provided when you registered your client. One additional query parameter (a code) will be added to your browser’s address bar, at the end of the redirect URL. The code parameter is a single use login code that we will now use to acquire an access token:

Redirect page
Redirect page

Open up a command prompt window (for Windows OS) or a terminal (for Mac OS) and compose the following curl command:

curl -X POST https://api.pinterest.com/v5/oauth/token --header "Authorization: Basic ENCODED_STRING" --header "Content-Type: application/x-www-form-urlencoded" --data-urlencode "grant_type=authorization_code" --data-urlencode "code=YOUR_CODE" --data-urlencode "redirect_uri=REDIRECT_URI"

You’ll need to replace a few values:

  • ENCODED_STRING – is the Base64-encoded string made of client_id:client_secret. client_id is your app_id and client_secret is the app secret key. You can use a site you trust such as https://www.base64encode.org/ to encode them.
  • YOUR_CODE – This should be the value of the code query parameter from the previous step
  • REDIRECT_URL – This must be the redirect URL that you’ve add to your app

Note: For Mac OS, you may need to use single quotes ( ‘ ) instead of double quotes ( ” )

Our request entered in the command prompt window:

The cURL command
The cURL command

In the response that you get back, your access token will be displayed.

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 4.) Choose a Pinterest endpoint

In this section, we’ll show you how to browse the Pinterest API documentation to find the endpoint that retrieves the data you need from Pinterest. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 5.

First, open the Pinterest API documentation page: https://developers.pinterest.com/docs/api/v5/

The menu on the left contains general information about the Pinterest API and a list of categorized endpoints.

Pinterest API documentation page
Pinterest API documentation page

If we click the Pins category, a list of its endpoints will be displayed:

The Pins category page
The Pins category page

An example endpoint is Get Pin, which returns a pin owned by the operation user_account, or present on a group board that has been shared with this account:

https://api.pinterest.com/v5/pins/pin_id

If you use this URL don’t forget to replace pin_id with your own value!

The endpoint’s documentation contains a short description of the endpoint’s purpose, its HTTP method (GET), the URI, the path parameters, the query parameters, the cURL command and example responses:

The Get Pin endpoint page
The Get Pin endpoint page

All API calls to Pinterest should be made to this base URL: https://api.pinterest.com/v5/

Step 5.) Enter your Pinterest 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, POST, PUT, etc) required by your API endpoint. For this example, we are using the GET method.

API URL: In Step 4, we explained how you can find the Pinterest REST API endpoint that you need. Now copy and paste your complete Pinterest 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 List boards endpoint, which get a list of the boards owned by the operation user_account + the group boards where this account is a collaborator. This is what the whole URL looks like:

https://api.pinterest.com/v5/boards

Headers: In the Headers section of Apipheny, add two rows with the following keys and values:

Header 1
Key:
Content-Type
Value:
application/json

Header 2
Key:
Authorization
Value:
Bearer your_token

In header 2’s value, make sure to replace your_token with the value of the API key you obtained previously, in Step 3. There should be a literal space between Bearer and your_token.

Pinterest API request entered into Apipheny
Pinterest API request entered into Apipheny

Step 6.) Run the Pinterest 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 Pinterest API data to be imported into your Google Sheet. Here’s what our request looked like when completed:

Pinterest data imported into Google Sheets
Pinterest data imported into Google Sheets


Crypto API tutorials and more:


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?