Salesforce is one of the world’s most popular customer relationship management platforms. In this tutorial, I’ll show you how to connect the Salesforce REST API to Google Sheets in 6 steps:

  1. Install the Apipheny Add-on
  2. Create a Salesforce API app
  3. Obtain an API access token
  4. Choose a Salesforce Endpoint URL
  5. Enter your Salesforce API request into Apipheny
  6. Run the Salesforce API request in your Google Sheet

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

To pull data from the Salesforce API to Google Sheets, first install and open the Apipheny Google Sheets add-on.

Apipheny is an easy to use API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, 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 next page:

Apipheny API integrator
Apipheny API integrator

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.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets, like so:

Opening the Apipheny API integrator
Opening the Apipheny API integrator

Step 2.) Create a Salesforce API app

  1. Login to salesforce. In your account Dashboard, from Setup, enter and search for “Apps” in the Quick Find box, and then select App Manager:
Select "App Manager"
Select “App Manager”
  1. Then on the next page click New Connected App
Click "New Connected App"
Click “New Connected App”
  1. Enter the connected app’s name, which displays in the App Manager and on its App Launcher tile, check the Enable OAuth Settings checkbox and write the callback URL:
Fill in the details on the "New Connected App" page
Fill in the details on the “New Connected App” page

4. Choose the scopes you want to use:

Choose your scopes and permissions
Choose your scopes and permissions

5. Click the Save button to finally create the app:

Click "Save" to create the app
Click “Save” to create the app

6. Change the IP Relaxation Setting:

Go to Apps = > App Manager and find your app. Click the corresponding arrow and choose Manage from the drop-down menu:

Click "Manage" next to your app name
Click “Manage” next to your app name

Click the Edit Policies button:

Click the "Edit Policies" button
Click the “Edit Policies” button

Change the IP Relaxation setting to Relax IP restrictions:

Click "Relax IP restrictions" and save
Click “Relax IP restrictions” and save

Step 3.) Obtain an access token

Open up a command prompt window (for Windows OS) or a terminal (for Mac OS) and write the command below to obtain a token:

curl -s -X POST -F grant_type=password -F client_id=YOUR_CLIENT_ID -F client_secret=YOUR_CLIENT_SECRET -F username=YOUR_USERNAME -F password=YOUR_PASSWORD

You’ll need to fill in a few parts:

  • YOUR_USERNAME and YOUR_PASSWORD are your credentials for Salesfsorce
  • YOUR_CLIENT_ID and YOUR_CLIENT_SECRET are the consumer key and consumer secret values of the app that you created in Step 2
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).

Executing this command will return your access token in the response:

Salesforce API access token
Salesforce API access token

Copy and paste this new token to safe place because you’ll need it in the next steps.

Step 4.) Choose a Salesforce Endpoint URL

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

First, open the Salesforce API documentation page:

The main part pf the page contains the basic URL that you should use, a table containing the endpoints, and a short description for each endpoint:

Salesforce API documentation
Salesforce API documentation

An example endpoint is Resources by Version, that lists available resources for the specified API version, including resource name and URI. This is the corresponding URL for that endpoint:

If you use this URL, don’t forget to replace yourInstance with your domain name.

The documentation for each endpoint contains a short description of the endpoint’s purpose, the URI, the response format (JSON, XML), the endpoint’s HTTP method (GET), the authentication method, and a list of the accepted API parameters:

Salesforce API endpoint documentation example
Salesforce API endpoint documentation example

Step 5.) Enter your Salesforce API URL 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 4, we explained how you can find the Salesforce REST API endpoint that you need. Now copy and paste your complete Salesforce 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 Info endpoint, that retrieves basic information about an Account object. This is what the whole URL looks like:

If you’re following this same example as us, just replace YOUR_INSTANCE with the domain you are using.

Headers: In the Headers section of the Apipheny add-on, add two API header rows with the following keys and values (if you’re following the same example as us):

Header 1
Bearer your_token

Header 2

your_token is the value of the token you obtained previously, in Step 3. There should be a literal space between Bearer and your_token.

Salesforce API request entered into the Apipheny add-on, including an API URL and two sets of header keys and values
Salesforce API request entered into the Apipheny add-on, including an API URL and two sets of header keys and values

Step 6.) Run the Salesforce API Request

Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the Salesforce API data to be imported into your Google Sheet.

Salesforce data imported into Google Sheets using the Salesforce API and the Apipheny add-on
Salesforce data imported into Google Sheets using the Salesforce API and the Apipheny add-on

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

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

Related articles:

Related Posts