tableau-api-lib (detailed): getting started
Вставка
- Опубліковано 10 чер 2024
- UPDATE to use the 'querying' functions seen in this video you will need to add the following import statement to your code (this import statement was accidentally removed just before recording the video):
from tableau_api_lib.utils import querying
In this video we cover everything you need to get started using tableau-api-lib, a Python library that gives you control over the Tableau Server REST API.
This tutorial is in 'detailed' format, meaning it is the longer version of this tutorial. A blitz version also exists which provides the essentials in ~5 minutes and can be viewed here:
• tableau-api-lib (blitz...
For a step-by-step written guide, check out the blog post version:
/ introducing-tableau-ap...
Python version used: 3.8
Coding environment: Jupyter Lab
Tableau Server REST API endpoint focus: Sign In, Sign Out
To install tableau-api-lib:
pip install -U tableau-api-lib
Join the Tableau Developer Program to get involved. It coms with a free Tableau Online developer site!
Thanks for the explanation man, its helping me a lot!! I would like to ask a question. My filters are in a different view called "Filters and Params", but the view i would like to dowload is "Market Dash". Is there a way to download "Market Dash" view by altering the filters of another? Thanks again for the help!!
Your video save my ass. You are legendary!
Excellent series, I just came across the latest one and decided to start from the beginning.
How did you get the "querying" class to be available @11:11?
Hey Jared, thanks! I must have accidentally deleted the import statement, sorry for the confusion.
That 'querying' section of the library can be imported by tossing an import statement at the top of your file:
from tableau_api_lib.utils import querying
@@devyx Thank You.
Hello, this has been a really easy tutorial to follow thankyou! I however am getting an error when trying to use the 'querying' function -
NameError: name 'querying' is not defined
I imported pandas and am version is 2.0.3, not sure why this doesn't work? Thanks for your advice!
What does a response code 405 mean?
{'error': {'summary': 'Method Not Allowed', 'detail': "The HTTP method 'GET' is not supported for the given resource", 'code': '405000'}}
Thanks for the very good explanation. I am very new to Tableau server. Would you please explain a bit what does environment mean? In what situations I might need to connect to different environments?
Hi Diana, congrats on diving in and learning more about Tableau Server! In this situation 'environment' simply means the unique details about the server you are connecting to.
Imagine that your organization has three different Tableau Servers, one for each of three departments. Or imagine that you are a consultant working with three different clients who each have their own server.
In such a situation, you might want to configure your connection information in one place. You could do this by defining the details for each server environment. You would define each environment separately because the address is different for each, they may be running on different versions of the software (and therefore use different API versions), and your credentials to log in will be different.
For example, right now I have a Tableau Server environment and a Tableau Online environment I am working with. I configure these in my own config file with the 'environment' name as 'tableau_server' and 'tableau_online', and then in my Python code I can simply reference the one I am currently working on by name when configuring my TableauServerConnection.
Hope that helps!
@@devyx thank you so much, you are amazing in explanation. looking forward to more videos. already subscribed
Is there a node.js version of tableau-api-lib? Is there a good library that's similar to this for React.js?
No, there is only a Python version of this library. However, you might find what you need in Tableau's JavaScript API.
Hi! Thank you for the video. Is this library suitable for Tableau Online?
Yes, the REST API works on Tableau Online. Tableau Online is kind of like a site you are renting from a massive Tableau Server, so do be aware that some endpoints will not be available (for example, you cannot be a Server Admin on Tableau Online and therefore you cannot use the Create Site endpoint).
You can see which endpoints are supported by Tableau Online on the Tableau REST API reference. I recommend using personal access tokens for authenticating with the REST API.
how did you get your site_name and url?
here what is site_name and site_url in config json object
Where can I get my Tableau Server link from ?
Thanks
Glad you got some benefit from the video!
Hi, how to get more than one page (100 entries) from the Json?
Hello Devyx,
During execution, I am receiving the below error.
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Also, I validated my config details json format online. It shows config details is valid json format.
Can you assist me here to fix the error.
Hey, I'm not able to replicate the issue -- everything is working as expected for me with my same setup. My guess is that something is not exactly how it should be in your config. If you can mock up how you are defining your config (share it as-is in terms of structure, but without revealing your actual server address and password or other sensitive details), then I might be able to identify the issue.
How did you resolve the https, SSL timeout error on port 443 ? Appreciate any inputs. Thanks !
If your server doesn't use SSL, you can toggle SSL for the TableauServerConnection via a boolean parameter when inititalizing the connection.
If your server does use SSL and you are getting this error, it is a networking issue rather than a code issue. Might want to check with your IT group if the server is air-gapped or if the REST API is disabled. Either of those would prevent you from reaching the server via API valls.
@@devyx Thanks for a lot for the info. I was install pip install certifi - - upgrade. The issue was resolved looks like it needed new CA cert files. But I have to tell you your videos are extremely helpful. Btw: I sent a e-mail yesterday. Thank you !
Can we download the data from the server? We are anticipating issues that the data from the extract may not load completely and are trying to automate a process of looking at the data to see if there are any discrepancies. Any thoughts that would help?
My advice is to avoid extracting the data if the volume is so large to encounter issues. Databases such as Snowflake can process large volumes of data quite well with a live connection (billion+ rows). Also to that end, more extracts means more storage required on your Tableau Server and more CPU required for backgrounder processes.
If you want to validate an extract compared to what exists in another system, my approach would be to compare high-level aggregates. For example, total revenue per day... If these high level aggregates do not align then you know something went wrong.
@@devyx It's not liking this line: conn = TableauServerConnection{config_json=config, env='tableau_dev'} . I'm not defining config_json or TableauServerConnection earlier but I see that you aren't either.
Any ideas why an error could come? The error is that these weren't defined earlier.
how to get enviroment name in cloud tableau?
Hi Devyx
I am looking for scenario where i would like to extract data from Rest API to Tableau, if you can comment on easy option it would be really helpful , and do we have any built in Tableau connecter which can connect to Rest API and pull the data to Tableau?
Hi Shekar, the easiest way to do this is to query the REST API, output the results to a file (JSON is easiest if you hit an endpoint returning nested columns) and then connect to that file with Tableau Desktop. Connecting to JSON gives you the option to automatically flatten nested columns.
The long-term solution I would personally use (and which I do use) is to build a process where you have scheduled tasks which query the REST API, insert the results into a database, and then your Tableau workbooks or datasources connect to that database. This takes more effort to build but is more scalable and saves time in the long run. You would need to have logic which flattens nested columns, assuming you want that data in a user friendly form.
@@devyx Thank you for the providing options, but in my case they are not allowing to dump data in any place, just asking to connect to Rest API and pull data to Tableau, long term solution which you mentioned is scalable, even i suggested same but it will take some time to implement for them, so for quick and dirty they are asking to pull data from Rest API, not sure how we can extract data from Rest API, I know we can do some calculations based on datasets using API, but pulling data from API seems challenging, if you tried please share the video, i will follow similar steps.
@@shekar34327 Hey Shekar, I understand the situation and it's a similar one I've been in many times! Hopefully this helps. Here is a link to an article and a UA-cam video. They are the same tutorial, but one is in written form with screenshots and the other is a video you can watch and follow along.
The full code is provided at the bottom of the written article. In this example, we are pulling permissions data from the REST API and outputting the data into a CSV file. We then connect to that CSV file using Tableau Desktop to interact with the results.
Article: towardsdatascience.com/query-tableau-workbook-permissions-for-all-groups-and-users-4ae4e4cc404
Video: ua-cam.com/video/JkKFqIM3o-w/v-deo.html
How can I get the console that you are using? In other words, where I can download the software(s) that you are using ? or How can I install the software(s) that you are using? or Do I have to install python first, then ipython then jupiter notebook then jupiter lab? thank you for all your help in advance - newby here
I have the software thank you.
Hi I am trying your approach of using Tableau server client to download data from our tableau server. But during sign in, its failing by SSL error
error:
SSLError: HTTPSConnectionPool(host='XXX', port=443): Max retries exceeded with url: /api/3.8/serverinfo (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)')))
can you please let me know how to resolve this issue.
Hey Venkatesh, SSL issues are an infrastructure issue unrelated to this library. Your IT/infra team should have some ideas on how to get your SSL certs sorted. A workaround which I do not recommend, but which is an option, is to bypass SSL entirely by setting the "ssl_verify" flag in your TableauServerConnection to "False". This of course is only viable for testing and is absolutely not recommended for production, as you never want to open your door to vulnerabilities.