Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How To Access Tableu API in Python

How To Access Tableu API In Python

This Rest API tutorial help to Access Tableau API using python.The Tableau Server provides an application programming interface (API) that help to programmer to do any task, which you manage by tabcmd.

The API allows user to manage users, workbooks, data connections, and other resources on the server. We can also create users or import them from Active Directory, publish workbooks, create, view, and delete data sources, and perform other actions on the server.

There are following HTTP verbs allows into API –

  • GET – To fetch record from server.
  • POST – To create new record into the server, The new data will send into payloads.
  • PUT – To update record into the server based on ID, The payloads will hold updated data.
  • Delete – To delete record from server using Rest API.

You can also Read :How To Consume CloudFlare API Using Python

How To Access Tableu API in Python

I am accessing users information using Tableau  API URI. The URI specifies the site, project, workbook, user, or other resource that you are fetching, adding, updating and deleting.We will use GET Http method to fetch record from server.The sample URI syntax as follow –

https://your-server/api/3.5/sites/site-id/groups/group-id/users

The URI holds the following information –

  • your-server – This is the name of Tableau Server or IP address.
  • site-id – It hold the site identifier value.
  • group-id – This is an ID for the group.

The site, groups, and other resources is a 16 hexadecimal values in the following format: 9a8b7c6d5-e4f3-a2b1-c0d9-e8f7a6b5c4d.

Let’s install Python dependency

We will use requests package to handle HTTP request into this application.You can install request and flask package using following command –

pip install requests
pip install flask

Create API to Get Tableu Site Users

Let’s create tableu.py file and added below code into this file.

from flask import Flask
from flask_restful import Resource, Api
from flask_cors import CORS
import requests

app = Flask(__name__)
CORS(app) ## To allow direct AJAX calls

@app.route('/getGroups', methods=['GET'])
def home():
   try:        
    headers = {'Tableau-Auth': 'tableau token', 'Content-Type': 'application/json'}
    url = "https://your-server/api/3.5/sites/site-id/groups/group-id/users";
    res = requests.get(url, headers=headers)

    return r.json()

   except Exception as e:
    print('unable to get groups.')
    print(e.strerror)

if __name__ == '__main__':
   app.run(debug = True)

The post How To Access Tableu Api in Python appeared first on Rest Api Example.



This post first appeared on Rest Api Example, please read the originial post: here

Share the post

How To Access Tableu API in Python

×

Subscribe to Rest Api Example

Get updates delivered right to your inbox!

Thank you for your subscription

×