truto-ts-sdk
is a TypeScript/JavaScript library to interact with the Truto API, a powerful integration platform for connecting multiple SaaS applications. The SDK mirrors the Truto REST API, endpoints which are documented in the Truto Postman Collection.
NodeJS 16+
Install the package via npm:
npm install @truto/truto-ts-sdk
or via yarn:
yarn add @truto/truto-ts-sdk
Here's an example of how to use @truto/truto-ts-sdk
:
import TrutoApi from '@truto/truto-ts-sdk'
const { default: TrutoApi } = require('@truto/truto-ts-sdk');
const trutoApi = new TrutoApi({
token: process.env.TRUTO_API_TOKEN,
})
// Fetch all installed integrations
const installedIntegrations = await trutoApi.environmentIntegration.list()
for await (const installedIntegration of installedIntegrations) {
console.log(installedIntegration)
}
// Fetch integrated accounts for a tenant
const integratedAccounts = await trutoApi.integratedAccount.list({
tenant_id: 'acme-1',
})
console.log(await integratedAccount.toArray()) // To fetch all
// Install an integration to the environment the API token is associated with
await trutoApi.integration.install('32b122db-ad24-400f-8ee7-0be21edc12ef')
// Make a request to the unified API
const unifiedApiCursor = await trutoApi.unifiedApi.list({
unified_model: 'accounting',
resource: 'accounts',
integrated_account_id: '766cc1ee-6637-4aa1-a73e-a0c89ccc867c',
created_at: '2023-05-01T00:00:00.000Z', // query parameters
// any other query parameters
})
for await (const unifiedApiResource of unifiedApiCursor) {
console.log(unifiedApiResource)
}
const unifiedApiResource = await trutoApi.unifiedApi.get('1', {
unified_model: 'accounting',
resource: 'accounts',
integrated_account_id: '766cc1ee-6637-4aa1-a73e-a0c89ccc867c',
})
console.log(unifiedApiResource)
We welcome contributions to improve truto-ts-sdk
. Please submit issues or pull requests on the GitHub repository.
MIT