RootFi’ server-side helper libraries (also known as server-side SDKs) reduce the amount of work required to use RootFi’ 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:
Copy
npm i rootfi-api
Next, import the RootFi client in your application code:
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.
Copy
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:
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 a connect link while specifying the company name, integration_categories and integrations:
Copy
// Create an Invite Linkconst 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:
Copy
// Get All Companiesconst 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:
Copy
// Fetch all accounts for your connectionconst data = await rootfi.accounting.accounts.list({ filter: { rootfi_company_id: { eq: 1323 }, rootfi_updated_at: { gt: "2023-05-12" }, },});