How to Download Tableau Dashboards Programmatically Using Python (Step-by-Step Guide)

Introduction

In modern data workflows, automating Tableau Server tasks is essential for saving time and reducing manual effort. One of the most common automation needs is downloading Tableau dashboards (workbooks) programmatically.

In this article, you will learn how to:

  • Connect to Tableau Server using Python
  • Authenticate securely
  • Find workbook IDs
  • Download Tableau dashboards/workbooks programmatically
  • Automate the entire process using tableauserverclient

This guide uses the official Tableau Server Client (TSC) library, which is the recommended way to interact with Tableau Server via Python.


🧰 Prerequisites

Before starting, ensure you have the following installed:

1. Install required libraries

pip install tableauserverclient pandas

2. Python environment

  • Python 3.7+
  • Access to Tableau Server or Tableau Cloud
  • Valid username/password or token credentials

πŸ” Step 1: Connect to Tableau Server

The first step is authentication with Tableau Server using TableauAuth.

from datetime import datetime
import tableauserverclient as TSC
import pandas as pd# Authentication
tableau_auth = TSC.TableauAuth('your_username', 'your_password')# Server connection
server = TSC.Server('https://your-tableau-server.com')

πŸ”‘ Step 2: Sign in to Tableau Server

Use the auth.sign_in() method to establish a session:

with server.auth.sign_in(tableau_auth):
print("Successfully connected to Tableau Server")

πŸ“₯ Step 3: Download Tableau Workbook (Dashboard)

If you already know the workbook ID, you can directly download it.

with server.auth.sign_in(tableau_auth):    workbook = server.workbooks.get_by_id("YOUR_WORKBOOK_ID")    file_path = server.workbooks.download(
workbook.id,
include_extract=False
) print("Downloaded file:", file_path)

βœ… Output

Downloaded file: C:\Users\YourName\Downloads\WorkbookName.twbx

πŸ”Ž Step 4: Find Workbook ID (If Unknown)

If you don’t know the workbook ID, you can retrieve all workbooks available on the server.

with server.auth.sign_in(tableau_auth):    all_workbooks = list(TSC.Pager(server.workbooks))    for wb in all_workbooks:
print("Workbook Name:", wb.name)
print("Workbook ID:", wb.id)
print("-" * 40)

This helps you identify the correct workbook before downloading.


πŸ“‚ Step 5: Save File to Custom Location

You can define a custom download path:

filepath = r"C:/Users/YourName/Downloads/tableau_workbook.twbx"

Then move or rename the downloaded file if needed:

import shutilshutil.move(file_path, filepath)
print("File saved at:", filepath)

⏱ Step 6: Log Execution Time (Optional)

Tracking execution time helps in automation pipelines:

print("Downloaded at:", datetime.today())

πŸš€ Full Working Script (Complete Example)

from datetime import datetime
import tableauserverclient as TSCtableau_auth = TSC.TableauAuth('your_username', 'your_password')
server = TSC.Server('https://your-tableau-server.com')with server.auth.sign_in(tableau_auth): # Get workbook (replace ID)
workbook = server.workbooks.get_by_id("YOUR_WORKBOOK_ID") # Download workbook
file_path = server.workbooks.download(
workbook.id,
include_extract=False
) print("Downloaded file:", file_path)print("Process completed at:", datetime.today())

πŸ”₯ Key Features of This Approach

  • Fully automated Tableau dashboard download
  • No manual UI interaction required
  • Works for scheduled ETL pipelines
  • Supports integration with Airflow, cron jobs, or CI/CD systems

⚠️ Best Practices

  • Use Personal Access Tokens (PAT) instead of username/password in production
  • Avoid hardcoding credentials
  • Handle exceptions for production scripts
  • Use logging instead of print statements
  • Validate workbook permissions before downloading

πŸ“Œ Common Use Cases

  • Automated reporting systems
  • Data backup from Tableau Server
  • DevOps analytics pipelines
  • Scheduled dashboard exports
  • Data warehouse integration workflows

🎯 Conclusion

Downloading Tableau dashboards programmatically using Python is simple and powerful with the tableauserverclient library. With just a few lines of code, you can automate workbook extraction and integrate Tableau into your data engineering pipelines.

If you’re working with Tableau at scale, this approach can save hours of manual work every week.


Click to rate this post!
Spread the love