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 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.) 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 a command prompt window (for Windows OS) or a terminal (for Mac OS). At the command prompt/terminal, 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.

Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).

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


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?


Sponsored by Zink Virtual Tip Jar & Rewording.io Paraphrasing Tool

Accept donations on Twitch | Accept donations on Discord | Accept donations on YouTube | Accept donations on Telegram | Accept donations on Twitter | Accept donations on TikTok | Accept donations on Instagram | Accept donations on LinkedIn | Accept donations on Facebook | Accept donations on your Website