Skip to main content

Introduction

The package name is totalum-api-sdk. Use the Totalum API SDK to query, filter, modify, create, and delete Totalum data without limits. You can also use the API SDK to generate PDFs, perform OCR on images or PDFs, access ChatGPT, and more.

Ways to Use the API SDK

Using the totalumSdk for JavaScript

This is the easiest way to use the API, as it is an npm package with TypeScript that provides autocomplete for methods and offers a simpler interface for interacting with the API.

Using the API Directly

If you do not want or cannot use the SDK, you can use the Totalum REST API directly.

ACCESS THE TOTALUM API DOCUMENTATION

Installation

Totalum SDK is an npm package, compatible with nodejs and browsers.

https://www.npmjs.com/package/totalum-api-sdk


npm i totalum-api-sdk

If you are using Totalum from a custom HTML and cannot import it with npm, use the following script:

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/totalum-sdk.min.js"></script>

Warning: We only recommend using TotalumSdk from the frontend in a custom HTML page within Totalum, or from a Totalum plugin or event. In all other cases, we recommend using the SDK from your own backend.

If you use TotalumSdk from your own frontend that is open to the public, anyone could see your authentication token or apiKey, and could use it intentionally.


Authentication

Note: If you use totalumSdk inside a totalum plugin, you don't need to authenticate, you can start using totalum like this: modules.totalumSdk.your.function(); -> example: modules.totalumSdk.crud.getRecords('your_table', {})

You can choose to use one of the two authentication methods offered by Totalum Sdk:

  • Token: You can use an access token to authenticate. This token can be obtained from the localStorage of your browser from the web https://web.totalum.app

  • ApiKey: (RECOMMENDED OPTION) You can use an ApiKey to authenticate. This ApiKey can be obtained in the Api Keys section of the Configuration section of Totalum.

ES Module Import:


import {AuthOptions, TotalumApiSdk} from 'totalum-api-sdk';

// CHOICE FROM USE accessToken OR apiKey (API KEY IS RECOMMENDED)

// the auth using token
const options: AuthOptions = {
token:{
accessToken: 'YOUR TOKEN' // get it from totalum project web localStorage
}
}

// the auth using api key
const options: AuthOptions = {
apiKey:{
'api-key': 'your_api_key', //the api key secret that is shown only once, example: sk_23r23r23r...
}
}

const totalumClient = new TotalumApiSdk(options);

// execute some TotalumApiSdk function
const result = await totalumClient.crud.getRecords('your_table_name', {});

CommonJS Require:


const totalum = require('totalum-api-sdk');

// CHOICE FROM USE accessToken OR apiKey (API KEY IS RECOMMENDED)

// the auth using token
const options = {
token:{
accessToken: 'YOUR TOKEN' // get it from totalum project web localStorage
}
}

// the auth using api key
const options = {
apiKey:{
'api-key': 'your_api_key', //the api key secret that is shown only once, example: sk_23r23r23r...
}
}

const totalumClient = new totalum.TotalumApiSdk(options);

// execute some TotalumApiSdk function
const result = await totalumClient.crud.getRecords('your_table_name', {});

HTML script import:

Use this way if you are using standalone html, and you cannot import npm packages


<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/totalum-sdk.min.js"></script>
</head>
<script>
//Example of use TotalumSdk in your custom html page
const token=localStorage.getItem('token');
var totalumClient = new totalumSdk.TotalumApiSdk({
token:{
accessToken: token
}
});

const tableName = 'your-table-name'; // replace with your table name

//example of endpoint execution
totalumClient.crud.getRecords(tableName, {}).then((result) => {
if (result.errors) {
console.error("ERROR:", result.errors);
return;
}
const records = result.data;
console.log("THE RECORDS", records);
});

</script>