Tableau REST API - Installation

The Tableau REST API is a great resource to help you automate any admin Tasks on your Tableau Server. This post will explain how to use the Tableau REST API on Python 2.7. I will use the awesome library created by the brilliant Bryant Howell. This post will explain how to get everything you need installed. If you already have Python 2.7, the library installed, to see what you can do with the library and the REST API go to Part 2 to see how you can programmatically:

  • delete old/useless content
  • download all of your workbook and datasource
  • automate the creation of users
  • affix data to a Tableau extract.

I would recommend you make your way directly to Bryant's blog who covers the library deeper than I. For a step-by-step guide you're in the right place.

Level required: Advanced on Tableau and basic coding skills.
Software required: Tableau Server and Python 2.7

Step 1: Python 2.7

I will assume you have a Tableau Server you can access with a login a password.
The next step consists of installing Python and PyPi. If you already have Python installed, you can go to Step 2 to download and install the library.

Install Python.

Download python 2.7 here.
If you are serious about coding in Python, I would recommend using PyCharm.

If you are not using PyCharm:
Once your Python is installed, make sure you can run it. Open a cmd line and go to C:Python27 then run "python". Make sure you have something that looks like this:


Add python to your environment path to make sure you can call the python cmd from anywhere.
right click on your computer, -> Advance System Settings then add a semicolon and the python path to your environment variable as shown below.

Now make sure you can run the cmd line. It is now shipped in any new python installation. Run "pip" as a command line.


Step 2: Install the REST API Library

Once pip is in working order, type the following command line to install the tableau REST API:

pip install tableau_rest_api
pip install tableau_rest_api --upgrade

Let's make sure everything works as it should by creating simple script that is going to use the library.
Open new file, and copy paste the following script. **Update your password & Login on line 11**.

import math
import xml.etree.ElementTree as ET # Contains methods used to build and parse XML
import requests  # Contains methods used to make HTTP requests
import sys
from tableau_rest_api.tableau_rest_api import *

print('Testing... By You')

logger = Logger(u"log_file.txt")

t = TableauRestApi(u"", u"admin", u"admin") #Connect to different stes

This script will use some libraries to make HTTP calls on our Tableau server. We'll understand what this code does in part 2 of this tutorial. For the moment let's run it and make sure everything works as it should. If you have several sites, you can specify which site you want to connect to by editing line 11

t = TableauRestApi(u"", u"admin", u"admin", site_content_url="test")

Instead of testing, look at your URL when you are on a specific site on your Tableau Server:


Go back to your tabcmd and run your new script with:


If everything worked well, you should get the following line prompted in your cmd line:


And you can read the Xml response from your Server here: C:Python27/log_file.txt.
So what have we done so far? Just logged in to our Tableau Server as a user and sent a simple HTTP request.

WHAAAT?!! All of that to just connect to my server?
Indeed. But now you are ready for the magic to begin in PART 2. You will learn how to manage your Tableau server from only a couple of lines of code.

Leave a Reply

Your email address will not be published.