Tableau API Lib is a Python library that allows developers to interact with Tableau Server's REST API. It mirrors the methods available in Tableau's official REST API documentation, providing an easy way to automate administrative tasks, manage content, and retrieve data from Tableau Server and Tableau Cloud. The library is currently at version 0.1.50 and typically updates to reflect changes and additions in the Tableau REST API.
pip install --upgrade tableau-api-libVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to establish a connection to Tableau Server or Tableau Cloud using either username/password or a Personal Access Token (PAT), query available sites, and properly sign out. It uses environment variables for sensitive credentials for better security practices.
Always test your code against the specific Tableau Server or Tableau Cloud version you intend to connect to. Monitor Tableau's official REST API documentation (developer.tableau.com/api-docs/rest-api/rest_api_ref) for breaking changes in new API versions and update your `api_version` in the config accordingly. Upgrade `tableau-api-lib` regularly to ensure compatibility and access to the latest REST API features.
Ensure you use `from tableau_api_lib.utils import querying` (or `from tableau_api_lib.utils.querying import get_sites_dataframe`) to access these helper functions. Not importing them correctly will result in an `ImportError` or `AttributeError`.
Always inspect the `.json()` output of a response object. Refer to Tableau's official REST API reference for the specific endpoint you are calling to understand the expected JSON structure and how to navigate it to extract the desired data. For example, `response.json()['sites']['site']` is common for lists of sites.
Verify your PAT details (name and secret) in Tableau Server/Cloud. Use `conn.sign_in_with_personal_access_token()` if you intend to use PATs explicitly. If you're mixing auth methods in your config, be aware of the precedence. Ensure PATs have sufficient permissions for the API calls being made.
Refer to Tableau's REST API documentation to confirm if a specific endpoint supports pagination. Ensure your `TableauServerConnection` is properly authenticated and has a valid token before attempting paginated queries. Check GitHub issues for `tableau-api-lib` for specific pagination-related known issues.