Automate and Integrate with Tableau
After completing this unit, you’ll be able to:
- Explain how you can manage Tableau servers, sites, workbooks, permissions, and other elements using the Tableau REST API.
- Describe how you can integrate REST API calls in Python using the Tableau Server Client library.
- Explain how you can use Tableau events to trigger your custom processes through webhooks.
Do Things the Easy Way
Automating tasks is a great way to save time and energy. Tableau enables you to automate installation, configuration, and site administration tasks. You can also programmatically manage Tableau Server content, including workbooks, data sources, and users. These APIs and tools can help:
- Tableau REST API: Manage and change Tableau Server or Tableau Cloud resources programmatically, using HTTP. Get access to the functionality behind the data sources, projects, workbooks, site users, and sites on a Tableau server to create your own custom applications or to script interactions.
- Tableau Server Client (TSC): Manage and change Tableau Server or Tableau Cloud resources using a Python library for the Tableau REST API.
- Webhooks: When events happen in Tableau, send notifications using standard web technologies such as HTTP and JSON to trigger a workflow.
- Metadata API: Discover and index the content on your Tableau Server or Tableau Cloud site and identify all of the databases, files, and tables used by the content.
- Hyper API: Automate your interactions with Tableau extract (.hyper) files. You can use the API to create new extract files, or to open existing files, and then insert, delete, update, or read data from those files.
- Tableau Services Manager (TSM): Manage installation and configuration of Tableau Server.
- The tabcmd command-line utility: Automate site administration tasks on your Tableau Server or Tableau Cloud site. For example, creating or deleting users, projects, and groups.
Use the Tableau REST API to Add Users
Now that Main Stage Analytics has adopted Tableau, every new employee gets a Tableau license. Let’s meet Jamie, who has an important role to play here. They are a Tableau Server administrator at Main Stage Analytics. Jamie’s team has to manually add these new employee licenses using the Tableau user interface, which is time-consuming. From a quick web search, Jamie learns that the Tableau REST API offers many ways to automate a variety of tasks, including using a simple script to add users instead of the Tableau UI. This API gives you access to the functionality behind data sources, projects, workbooks, site users, and sites. Jamie is happy to know that they can start to automate tedious tasks.
Use Tableau Server Client to Integrate REST API Calls
This helps, but Jamie’s team finds it easy to make small errors that are time-consuming to untangle. Jamie discusses the issue with Marie, a coworker who is a software engineer. Marie mentions that it’s easy to integrate Tableau REST API calls into existing processes using the Tableau Server Client (TSC), a Python library for the Tableau REST API. By adding a few lines of code that call the client, they can integrate the REST API “add user” call into their existing new hire provisioning scripts. Jamie does a happy dance, because now licenses for new employees are granted automatically, with no impact on Jamie’s team.
Use Webhooks to Trigger Messages on Tableau Events
On the other hand, Jamie learns that the team is not aware of some data source refresh failures fast enough. They get an email every time a refresh fails but it would be more convenient to get the notification on their messaging application. They can add a webhook that will send a message to the team’s messaging application channel whenever a failure occurs. Indeed, webhooks allow other services like Slack to respond to events that happen on Tableau such as an extract refresh failure. With a little help from Marie, a webhook is put in place, Jamie’s team can restart failed refreshes immediately, and stakeholder complaints drop substantially.
Use the Metadata API to Gather Information About Your Tableau Deployment
The adoption of Tableau is growing at Main Stage Analytics. That means more users creating content, but also more workbooks and data sources on Tableau. Tableau users love how easy it is to create calculations on the fly, but Jamie’s team notices that users often forget to delete their calculations or rename them to something meaningful. They have a dozen calculations called “Calculation 1”, for example, and how can other users know whether “Calculation 1” is for “Profit” or for “Discount” or for something else? Even their team doesn't know. They need the user who created the calculation to rename it or delete it if they don’t need it. The team decides to use the Tableau Metadata API to find all of the poorly named calculations and email the calculation owners asking them to rename the calculations.
The Metadata API allows you to query for resources on Tableau and how they relate to other assets. You can use it to:
- Discover data that’s associated with the content published to Tableau.
- Track lineage or the relationships between content and external assets, like data sources and workbooks, and their tables or files.
- Perform impact analysis. Using upstream and downstream lineage information, you can evaluate impact of changes to content.
Use the Tableau Hyper API to Integrate Your ETL Tools
Before using Tableau, some teams at Main Stage Analytics use extract, transform, and load (ETL) tools to clean up data sources. After they prepare the data, these teams want to be able to push it to Tableau. Their favorite way to do this is to create a Tableau Hyper file (.hyper), using the Tableau Hyper API. The Hyper API allows them to automate the ETL process, and lets them implement rolling window updates and custom incremental updates. Using the Tableau REST API and the Tableau Server Client (TSC), the teams can publish the .hyper files to Tableau Server and Tableau Cloud.
The Tableau Hyper API allows you to create new extract files and improve data access and performance. It also lets you open existing files, and then insert, delete, update, or read data from those files. Using the Hyper API, developers and administrators can:
- Create extract files for data sources not currently supported by Tableau.
- Load data directly from CSV files very quickly and without having to write special code.
- Use the power of SQL to interact with data in .hyper files.