REST API v2 SDK

REST API v2 SDK

ThoughtSpot provides native SDK libraries to help client applications call REST APIs in a specific language format.

Currently, the REST API client libraries are available for TypeScript. This client library includes classes that correspond to the resource elements and data types that the API uses when processing requests and responses.

Setup and usage🔗

The REST API SDK library for TypeScript is available on the NPM site.

To get started, install the SDK. Navigate to the folder of your consuming project and run the following command:

npm install @thoughtspot/rest-api-sdk --save

After you install the SDK, set up authentication and make an API request. The following code snippet shows how to call the searchUsers method.

import {
  ThoughtSpotRestApi,
  createBearerAuthenticationConfig
} from "@thoughtspot/rest-api-sdk";

const BASE_URL = "CLUSTER_URL";

const main = async () => {
  // get the authentication token
  const config = createBearerAuthenticationConfig(BASE_URL, {
    username: "YOUR_USERNAME",
    password: "YOUR_PASSWORD",
  });

  // create a ThoughtSpot client
  const tsRestApiClient = new ThoughtSpotRestApi(config);

  try {
    const users = await tsRestApiClient.searchUsers();
    console.log("Users on the cluster : ");
    users.forEach((user) => {
      console.log(user.name, user.email);
    });
  } catch (e) {
    console.log(e);
  }
};

main();

For a complete list of methods to use for API calls and examples, see RESt API SDK Resources.

SSL certificate🔗

For self-certified SSL certificates, configure the following environment variable:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"

Additional resources🔗

For more information about REST APIs and REST API SDK, use the following resources:

  • For information about supported authentication types, see REST API v2 authentication.

  • Browse through the REST API v2 Playground before you start constructing your API requests. The playground offers an interactive portal with comprehensive information about the API endpoints, request and response workflows.

  • For information about supported API endpoints, see REST API v2 reference

  • For information about supported Methods, Classes, and examples, go to REST API SDK Resources.