# rootfi-api

> The RootFi Node.js library provides convenient access to the RootFi API from applications written in server-side JavaScript.

Latest version **3.2.2** (published 2024-12-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install rootfi-api
pnpm add rootfi-api
yarn add rootfi-api
bun add rootfi-api
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.2 |
| Published | 2024-12-26 |
| First published | 2023-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 3.5 MB |
| Known vulnerabilities | 0 (+33 in 2 direct dependencies) |
| Install scripts | no |
| Maintainers | ans2000, parth.shah.rootfi |

## Links

- npm: https://www.npmjs.com/package/rootfi-api
- npm.io page: https://npm.io/package/rootfi-api

## Dependencies (5)

- [axios](https://npm.io/package/axios.md) 1.6.7
- [url-join](https://npm.io/package/url-join.md) 4.0.1
- [form-data](https://npm.io/package/form-data.md) 4.0.0
- [js-base64](https://npm.io/package/js-base64.md) 3.7.6
- [@ungap/url-search-params](https://npm.io/package/@ungap/url-search-params.md) 0.2.2

## Recent versions

- 3.2.2 (latest) — 2024-12-26
- 3.2.1 — 2024-12-18
- 3.2.0 — 2024-12-18
- 3.1.9 — 2024-12-18
- 3.1.8 — 2024-08-29
- 3.1.7 — 2024-07-04
- 3.1.6 — 2024-07-04
- 3.1.5 — 2024-07-02
- 3.1.4 — 2024-06-27
- 3.1.3 — 2024-06-27
- 3.1.2 — 2024-06-27
- 3.1.1 — 2024-06-27
- 3.1.0 — 2024-06-26
- 3.0.29 — 2024-06-26
- 3.0.28 — 2024-06-26
- … 32 more at https://npm.io/package/rootfi-api/versions

## README

# RootFi Node Library

The RootFi Node.js library provides convenient access to the RootFi API from applications written in server-side JavaScript.

## Documentation

See the [API docs](https://docs.rootfi.dev) for more information about the API.

## Installation

```
npm install --save rootfi-api
# or
yarn add rootfi-api
```

## Instantiation

```typescript
import { RootFiClient } from "rootfi-api";

const rootfi = new RootFiClient({
    apiKey: "ROOTFI_API_KEY",
});
```

## Namespaces

The RootFi SDK is organized into categories, each with its own namespace. The available categories are:

-   `core`: APIs for managing companies and invite links
-   `accounting`: APIs for managing invoices, bills, and other accounting-related data
-   `ecommerce`: APIs for managing orders, products, and other e-commerce-related data
-   `payments`: APIs for managing payments and other payment-related data
-   `crm`: APIs for managing customers and other CRM-related data

```typescript

const rootfi = new RootFiClient({
  apiKey: 'ROOTFI_API_KEY',
});

rootfi.accounting. // APIs specific to the Accounting Category

rootfi.payments. // APIs specific to the Payments Category
```

## Usage

Below are code snippets of how you can use the RootFi Typescript SDK.

### Get Invoices

```typescript
import { RootFiClient } from "rootfi-api";

const rootfi = new RootFiClient({ apiKey: "ROOTFI_API_KEY" });

invoices = await rootfi.accounting.invoices.list({ limit: 10, rootfiCompanyID: 234 });
```

### Get Orders

```typescript
import { RootFiClient } from "rootfi-api";

const rootfi = new RootFiClient({ apiKey: "ROOTFI_API_KEY" });

orders = await rootfi.ecommerce.orders.list({ limit: 10, rootfiCompanyID: 234 });
```

### Get Companies

```typescript
import { RootFiClient } from "rootfi-api";

const rootfi = new RootFiClient({ apiKey: "ROOTFI_API_KEY" });

const companies = await rootfi.core.companies.list({ limit: 10 });
```

### Paginate Data

RootFi follows cursor-based pagination. The response will include a `next` and `prev` property. To get the next page, you can pass in the value of `next` to the cursor property on the request. Similarly, to get the previous page, you can pass in the value of `prev` to the cursor property on the request.

```typescript
import { RootFiClient } from "rootfi-api";

const rootfi = new RootFiClient({ apiKey: "ROOTFI_API_KEY" });

const orders = await rootfi.ecommerce.orders.list({
    limit: 10,
    rootfiCompanyID: 234,
    next: "eyJyb290ZmlfaWQiOjE4ODA2MDZ9",
});
```

### Create Account

```typescript
import { RootFiClient } from "rootfi-api";

const rootfi = new RootFiClient({ apiKey: "ROOTFI_API_KEY" });

await rootfi.core.inviteLinks.create({
    company_name: "Test Company",
    integration_category: ["ACCOUNTING"],
});
```

### Sample Code for Fetching and Saving Data

Below is a sample code for fetching and saving data from the RootFi API to your database. You can use this as a starting point to build your own data sync process.

```typescript
import { RootFiClient } from "rootfi-api";
const rootfi = new RootFiClient({ apiKey: "ROOTFI_API_KEY" });

async function fetchAllData() {
    let nextCursor = null;

    do {
        const response = await rootfi.accounting.invoices.list({ next: nextCursor, limit: 100 });
        const data = response.data;

        // Save data to your database

        nextCursor = response.next;
    } while (nextCursor);
}
```

---
_Source: https://npm.io/package/rootfi-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
