REST API SDK

JavaScript SDK wrapper for the ThreeKit REST APIs

This SDK enables developers to access the REST API endpoints without the need to use fetch, or libraries like Axios. By installing the sdk package in your node.js application you can directly access these endpoints without having to remember the URL or required parameters.

Currently, this SDK does not include all available API endpoints or properties. Going forward, ThreeKit will maintain the SDK concurrently with the REST API endpoints, ensuring parity with every release.

Installation

You may install the sdk package in your node.js application using the following command:

npm i @threekit/rest-api

Getting Started

In order to access the methods for the different API endpoints, users must first define a ThreeKitClient variable using the following:

import { ThreekitClient } from "@threekit/rest-api";

const client = new ThreekitClient({  
    orgId,  //your ThreeKit orgId
    host: "preview.threekit.com",  //the hostname URL of the environment where that org exists
    privateToken,  //your Private Token from the org listed above
  });

The ThreeKitClient can allow for several different methods of authentication, using either a privateToken, publicToken, or a cookie.

Using the Cookie method

Using a cookie for authentication is available only in the case where the web app will be installed in that org, such as these example general apps.

ThreeKit will pass a cookie in the URL parameter to the installed app, through a token param, in addition to an orgId, appid, hostname and branch params.

In this instance, the orgId will always be required for authentication in addition to the cookie, and all the APIs need to be accessed from a backend server.

Usage Example

Let's take a look at an example where we would like to return a list of all items tagged with the tag "TEST" from a particular org.

import { ThreekitClient } from "@threekit/rest-api";

async function GetAssetsExample () {
  const client = new ThreekitClient({  
      orgId,  //your ThreeKit orgId
      host: "preview.threekit.com",  //the hostname URL of the environment where that org exists
      privateToken,  //your Private Token from the org listed above
    });

  try {
    const response = await client.assets.get({type: 'item', tags: ['TEST'] });
    console.log (response);
  } catch (error) {
    console.log ("Error reading asset list: ", error);
  }
}

Here we make use the of the client.assets.get method, corresponding to this Get Assets API endpoint.

In VSCode you can get additional context information when you type in the .after client, to see a list of available methods. In addition to that, using Ctrl+Click on the element in your code will take you to the context for that element, providing additional detail in terms of available parameters and their types.

List of Categories

Here is a list of the SDK categories, and their corresponding REST API categories:

SDK CategoryREST API Category
analyticsAnalytics
assetJobsAssets & Catalog - Import & Export Jobs
assetsAssets & Catalog - Simple
assetsV2Assets & Catalog - Granular
catalogAssets & Catalog - Legacy
datatablesData Tables
fastCompositorFast Compositor
filesFile Service
images
jobsJobs, Job Tasks and Job Runs
layersLayers Service (Renders & AR)
ordersOrders
orgsOrgs
pdfPDF Service
productsAssets & Catalog - Bulk
savedConfigurationsSaved Configurations
tagsTags
translations
users
webhooksWebhooks