Tableau is a popular data visualization software. In this tutorial, you will learn how to connect the Tableau REST API to Google Sheets in 5 steps:

  1. Install the Apipheny add-on
  2. Sign in to your server with REST
  3. Obtain an Endpoint URL
  4. Enter your Tableau API request into Apipheny
  5. Run the Tableau API request in your Google Sheet

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

To pull data from the Tableau API to Google Sheets, 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 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 page: https://gsuite.google.com/marketplace/app/apipheny/966163326746

Installing the Apipheny add-on
Installing the Apipheny add-on

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons or Extensions option in the top menu. In the extensions/add-ons menu, you should see Apipheny.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.

Opening the Apipheny add-on
Opening the Apipheny add-on

Step 2.) Sign in to your server with REST

After logging into your Tableau account, follow these next instructions:

Copy paste the following request body to an XML file named signin.xml:

 <tsRequest>
             <credentials name="USERNAME" password="PASSWORD">
                         <site contentUrl="SITE_NAME" />
             </credentials>
 </tsRequest> 

Don’t forget to replace:

  • USERNAME with your username
  • PASSWORD with your password
  • SITE_NAME with your site name

Then open a terminal window. At the command prompt, navigate to the directory where you saved signin.xml. Replace “MY_SERVER” with the name of your server in the following command, and then run it as follows:

cd /…/<dir-containing-sign-in-xml>

curl "https://MY-SERVER/api/3.4/auth/signin" -X POST -d "@signin.xml"

Don’t forget to replace MY-SERVER with the name of your server.

In the response, you will receive these credentials: token, site id, and user id. Save these values to a safe location, because you’ll need them in the next steps.

Obtaining site ID, user ID, and token
Obtaining site ID, user ID, and token

Step 3.) Choose your Endpoint URL

In this section, I’ll show you how to browse the Tableau API documentation to find an API endpoint URL that retrieves the specific information you need from your Tableau account.

If you already know your API URL, or you want to use the same example URL as us, just skip to Step 4.

First, open the Tableau API documentation page: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#

The main section contains a description of the Tableau REST API and links to resources for different API versions, including the current one:

Tableau API documentation
Tableau API documentation

The menu on the left contains a list of available Tableau API categories, each with its own endpoints:

Tableau API endpoints
Tableau API endpoints

For example, when clicking the Site Methods category in this menu, in the main section you should see a short description of the category and of its endpoints:

Tableau API endpoint documentation example
Tableau API endpoint documentation example

Each endpoint’s documentation contains a short description of that endpoint’s purpose, its URI, request body, attribute values, permissions and headers, as well as request examples:

Tableau API endpoint documentation example
Tableau API endpoint documentation example

All API calls to Tableau are made to this base URL:

https://SERVER_NAME/api/3.9/

All endpoints should be appended to this base URL. Don’t forget to replace SERVER_NAME with your server.

Step 4.) Enter your Tableau API URL Into Apipheny

Now, to get your Tableau data in your Google Sheet, go back to your spreadsheet and make sure that you’ve installed the Apipheny add-on and you have it opened on the “Import” tab.

In the Import Tab, enter the following details into the Apipheny add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) required by your Snapchat API endpoint. For this example, we are using the “GET” method.

API URL: In Step 3, we explained how you can find the Tableau API endpoint that you need. Now copy your complete Tableau API URL into the Apipheny add-on, in the field that says API URL Path (JSON / CSV), followed by any GET parameters required for your query (if applicable). For this example, we are using the Query Site endpoint, which returns information about the specified site. The corresponding URL for this endpoint is:

https://SERVER_NAME/api/3.9/sites/SITE_ID

If you’re following the same example as us, you can copy and paste this URL into the “API URL” field in the add-on. Don’t forget to replace SERVER_NAME with your server and SITE_ID with your site id, which you obtained in previous steps.

Headers: In the API headers section of the Apipheny add-on panel, add two rows, with the following key and value:

Header 1
Key:
X-Tableau-Auth
Value:
<your_token>

Header 2
Key:
Accept
Value:
Application/json

<your_token> is the value of the token you obtained previously, in Step 2. Here’s what your API request should look like when entered into Apipheny, if you’re following the same example as us:

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

Step 5.) Run the Tableau API request

Lastly, click the Run button at the bottom of the Apipheny add-on and then wait for the Tableau API data to be retrieved and added to your Google spreadsheet:

Tableau API data imported into Google Sheets using Apipheny
Tableau API data imported into Google Sheets using Apipheny

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

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

Related articles:

Related Posts