The TSC samples are included in the
samples directory of the TSC repository on Github.
Each of the samples accepts the following arguments:
--server(required): The URL for the Tableau Server that you want to connect to.
--site(optional): The site on the Server that you want to connect to.
--token-name(required): The name of the personal access token used to sign into the server.
--token-value(required): The value of the personal access token used to sign into the server.
error): The desired log level.
To get a
token-value, you will have to create personal access token first.
You can follow Tableau’s documentation to do so.
Some of the samples also require additional arguments. For more information about the arguments
required by a particular sample, run the sample with the
For example, if you run the following command:
python samples/publish_workbook.py -h
You will see that you need to enter a file path for the workbook that you want to publish.
The following list describes the samples available in the repository:
add_default_permission.pyAdds workbook default permissions for a given project.
create_group.pyCreates a user group.
create_project.pyCreates a project in a site.
create_schedules.pyCreates schedules for extract refreshes and subscriptions.
download_view_image.pyDownloads an image of a specified view.
explore_datasource.pyQueries datasources, selects a datasource, populates connections for the datasource, then updates the datasource.
explore_webhooks.pyExplores webhook functions supported by the Server API.
explore_workbook.pyQueries workbooks, selects a workbook, populates the connections and views for a workbook, then updates the workbook.
export.pyExports a view as an image, PDF, or CSV.
export_wb.pyExports a PDF containing all views in a workbook.
filter_sort_groups.pyDemonstrates filtering and sorting user groups.
filter_sort_projects.pyDemonstrates filtering and sorting projects.
initialize_server.pySets up an existing server instance with site, workbooks and datasources.
kill_all_jobs.pyKills all running jobs.
list.pyLists all datasources or workbooks of a site.
login.pyDemonstrates logging in to the server with either username/password or personal access token.
metadata_query.pyUses the metadata API to query information on a published data source.
move_workbook_projects.pyMoves a workbook from one project to another.
move_workbook_sites.pyDownloads a workbook, stores it in-memory, and uploads it to another site.
pagination_sample.pyUses the Pager generator to iterate over all the items on the server.
publish_datasource.pyPublishes a datasource to a server.
publish_workbook.pyPublishes a workbook to a server.
query_permissions.pyQueries permissions of a given resource.
refresh.pyRefreshes a datasource or workbook.
refresh_tasks.pyLists and runs configured tasks on a server.
set_http_options.pyDemonstrates HTTP options for the server and specifically for downloading workbooks.
set_refresh_schedule.pySets the schedule to refresh a workbook or datasource.
update_connection.pyUpdates and embeds connection credentials of a datasource.
update_datasource_data.pyUpdates the data within a published live-to-Hyper datasource.
Note: For all of the samples, ensure that your Tableau Server user account has permission to access the resources. Also keep in mind that some example operations (like create group) are not allowed on Tableau Cloud.