Using ThoughtSpot's REST API from Python

ThoughtSpot's documentation at lists JavaScript as a method of calling the REST API. In this article, we take a look at how to invoke the REST APIs from Python.

Why Python

Personally, I prefer Python to JavaScript as a programming language. Python is also better suited to creating helper utilities.


To follow along and code, you need the following:

import requests

What are the REST endpoints available?

ThoughtSpot REST endpoints vary by release, and are documented at

The endpoints of your existing installation can be accessed by going to your browser (Chrome, Firefox) :



(assuming <tspath> is an example installation like

Creating your connection: Login and State

ThoughtSpot has APIs for login and logout as documented at

Here is how you use it

        username = 'me'
        password = 'mysecurepassword'
        login = + "/callosum/v1/session/login",
                              headers={'Accept': 'application/json', 'X-Requested-By': 'ThoughtSpot'}

If the login is successful, we can store the returned state into a variable called cookie_jar.

        if login.status_code == 200:
            print("Login Success")
            cookie_jar = login.cookies

Invoking other APIs

Post requests to other APIs can now use this cookie information.

  • API to create user
        create_data = {}
        create_data['name'] = 'anotheruser'
        create_data['password'] = 'anotherusersecurepassword'
        create_data['displayname'] = 'Another User'
        create_data['groups'] = 'GROUP101'
        create_data['usertype'] = 'LOCAL_USER'
        create_data['tenant_id'] = '1'
        create_data['visibility'] = 'DEFAULT'

        createuser = + "/callosum/v1/session/user/create",
                              headers={'Accept': 'application/json', 'X-Requested-By': 'ThoughtSpot',

Check the return status code of the request, 200 indicates success.

  • API to get pinboard data

Using the example from, we can get data for a pinboard id and visualization by giving the IDs


        id = "05a69dc0-c557-4a8d-9bf1-24e1138e2747"
        vizid = "9c6b98e0-beac-4be5-b30e-68d18cc1a8a1"
        pin_data = + '/callosum/v1/tspublic/v1/pinboarddata?id=' + id + '&vizid=[' + vizid + ']&batchsize=-1&pagenumber=-1&offset=-1&formattype=COMPACT',
                               headers={'Accept': 'application/json', 'X-Requested-By': 'ThoughtSpot',

If the requests succeeds, you can get the JSON data.

        if pin_data.status_code == 200:
            print("get pin data Success")


Hope this helps all the developers/power users trying to use the REST API, and allow them to use the power of the REST APIs from Python.

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 2 wk agoLast active
  • 33Views
  • 1 Following