Installation

RootFi’s server-side helper libraries (also known as server-side SDKs) reduce the amount of work required to use RootFi’s REST APIs, starting with reducing the boilerplate code you have to write. Below are the installation instructions for these libraries in a variety of popular server-side programming languages.

Open your project folder and run the following bash command on your terminal to install the RootFi SDK in your preferred language:

npm i rootfi-api

Next, import the RootFi client in your application code:

import { RootFiClient } from "rootfi-api";

Instantiate RootFi

In your server file, instantiate the RootFi instance with your apiKey. You should generate the API keys on the RootFi Dashboard and add them here.

const rootfi = new RootFiClient({ apiKey: "<api_key>", environment: RootFiEnvironment.global });
// default environment is RootFiEnvironment.global
// For the KSA region use RootFiEnvironment.saudi

The resources can be accessed using the instance. All the methods invocations follow the namespaced signature:

Run your first SDK request

Now that you have the Node.js SDK installed, you can access RootFi’s APIs.

1. Core API
2. Unified API

To demonstrate Core APIs, we use the following JavaScript code snippet to make a Create request for creating an invite link. In this example, we create an invite link while specifying the company name, integration_categories and integrations:

// Create an Invite Link
const data = await rootfi.core.inviteLinks.create({
  company_name: "Test Company",
  integration_categories: ["ACCOUNTING"]
  integrations: ["ZOHO_BOOKS"],
});

To demonstrate Core APIs for fetching a list of all companies, you can use the following JavaScript code snippet:

// Get All Companies
const data = await rootfi.core.companies.list({});

To demonstrate Unified Accounting APIs, we are using the following JavaScript code snippet to make a List request for accounting data. In this example, we fetch all accounts for a specific connection based on certain filters:

// Fetch all accounts for your connection
const data = await rootfi.accounting.accounts.list({
  filter: {
    rootfi_company_id: { eq: 1323 },
    rootfi_updated_at: { gt: "2023-05-12" },
  },
});