📌 Developers & APIs | Resources
Ciara Brennan (Tableau)
📌 Join the Tableau Developer Program and start learning how you can build on the Tableau Developer Platform to fit your organization's unique needs. You'll get everything you need to keep your skills sharp, including tutorials, webinars, the latest news, and even your own personal development site. You will also get access to thousands of DataDevs members for networking, troubleshooting, Q&As, and expert insights.
Rushil Rawat (Member) asked a question.
import tableauserverclient as TSC
from datetime import datetime
# Tableau server details
server_url = ''
site = ''
token_name = ''
token_value = ''
# Sign in to Tableau Server
tableau_auth = TSC.PersonalAccessTokenAuth(token_name, token_value, site_id=site)
server = TSC.Server(server_url, use_server_version=True)
server.add_http_options({'timeout': 300 * 60})
def list_dashboards(server):
"""Fetch and list all dashboards."""
dashboards = list(TSC.Pager(server.workbooks))
print("\nAvailable Dashboards:")
for i, dashboard in enumerate(dashboards, start=1):
print(f"{i}. {dashboard.name}")
return dashboards
def list_sheets(workbook):
"""List all sheets in a given workbook."""
server.workbooks.populate_views(workbook)
sheets = workbook.views
print(f"\nAvailable Sheets in Dashboard '{workbook.name}':")
for i, sheet in enumerate(sheets, start=1):
print(f"{i}. {sheet.name}")
return sheets
def parse_filter(filter_input):
"""Parse the filter input into a field and a list of values."""
if ':' in filter_input:
field, values = filter_input.split(':', 1) # Split on the first occurrence of ':'
# Split multiple values into a list
value_list = [v.strip() for v in values.split(',')]
return {"field": field.strip(), "values": value_list}
return None
def apply_filters_and_download_pdf(server, selected_view, filters, pdf_filename):
"""Apply multiple filters and download a screenshot of the filtered sheet as a PDF."""
pdf_request_options = TSC.PDFRequestOptions(
page_type=TSC.PDFRequestOptions.PageType.A4,
orientation=TSC.PDFRequestOptions.Orientation.Landscape
)
# Apply each filter
for filter_item in filters:
field = filter_item["field"]
values = filter_item["values"]
# Combine multiple values into a single filter string
filter_string = ",".join(values)
pdf_request_options.vf(field, filter_string)
# Fetch the filtered view as a PDF
server.views.populate_pdf(selected_view, pdf_request_options)
with open(pdf_filename, "wb") as pdf_file:
pdf_file.write(selected_view.pdf)
print(f"\nFiltered PDF saved as: {pdf_filename}")
# Main process
with server.auth.sign_in(tableau_auth):
# List dashboards and prompt user to select one
dashboards = list_dashboards(server)
dashboard_index = int(input("\nEnter the number of the dashboard you want to use: ")) - 1
selected_dashboard = dashboards[dashboard_index]
# List sheets in the selected dashboard
sheets = list_sheets(selected_dashboard)
sheet_index = int(input("\nEnter the number of the sheet you want to use: ")) - 1
selected_sheet = sheets[sheet_index]
# Gather filters from the user
filters = []
while True:
print("\nEnter filter and value (format: 'field:value1,value2') or type 'done' to finish:")
filter_input = input("Enter filter (e.g., 'Category:Table,Chair'): ").strip()
if filter_input.lower() == 'done':
break
filter_item = parse_filter(filter_input)
if filter_item:
filters.append(filter_item)
else:
print("Invalid filter format. Please use the format 'field:value1,value2'.")
if filters:
# Capture a screenshot of the filtered sheet and save it as a PDF
pdf_filename = f"{selected_sheet.name}_filtered_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf"
apply_filters_and_download_pdf(server, selected_sheet, filters, pdf_filename)
else:
print("\nNo filters applied. Exiting.")
Ankit Gada (Member) asked a question.
I want to create Tableau Extension that connect Download an image from dashboard and publish the image to Google Gemini. Google Gemini can analyze this image and provide a summary details of the dashboard and insights around it that can be shown in the dashboard. What are the required resources and tools that will be required for this implementation?
Gayan Athukorala (Member) asked a question.
Hi everyone! I'm trying to build a docker image with the tableauhyperapi package, however when I try building the image, I get the following error:
=> ERROR [3/3] RUN pip install tableauhyperapi 0.4s
------
> [3/3] RUN pip install tableauhyperapi:
0.380 ERROR: Could not find a version that satisfies the requirement tableauhyperapi (from versions: none)
0.380 ERROR: No matching distribution found for tableauhyperapi
I can install the package fine on my laptop (Mac w/ M1 Chip), I only get this error when I try building a docker image with it.
Here is my dockerfile
FROM python:3.8-slim
RUN pip install tableauhyperapi
Any help would be greatly appreciated!
Please check out our post with some tips on asking a question and how to help you get answers more quickly.
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.