# @therootnetwork/api

> A utility package that complements the `@polkadot/api` to connect and interact with the Root Network node.

Latest version **1.1.0** (published 2025-07-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @therootnetwork/api
pnpm add @therootnetwork/api
yarn add @therootnetwork/api
bun add @therootnetwork/api
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2025-07-18 |
| First published | 2023-06-15 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 413.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | karishma09, aidan-starke, zees-fv, kenvu-ai |

## Links

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

## Recent versions

- 1.1.0 (latest) — 2025-07-18
- 1.0.7-next.1 (next) — 2024-01-30
- 1.0.14 — 2025-05-28
- 1.0.13 — 2025-05-27
- 1.0.12 — 2025-02-18
- 1.0.11 — 2025-01-20
- 1.0.10 — 2025-01-15
- 1.0.9 — 2024-06-25
- 1.0.8 — 2024-04-02
- 1.0.7 — 2024-02-12
- 1.0.7-next.0 — 2024-01-30
- 1.0.6 — 2023-11-20
- 1.0.5 — 2023-08-30
- 1.0.4 — 2023-08-28
- 1.0.3 — 2023-08-11
- … 3 more at https://npm.io/package/@therootnetwork/api/versions

## README

# @therootnetwork/api

A utility package that complements the `@polkadot/api` to connect and interact with the Root Network node.

## Install

```bash
yarn add @polkadot/api @therootnetwork/api
yarn add -D @therootnetwork/api-types # optional, for Typescript support
```

## Usage

- Create an API instance

```typescript
import "@therootnetwork/api-types"; // optional, for Typescript support
import { ApiPromise } from "@polkadot/api";
import { getApiOptions, getPublicProvider } from "@therootnetwork/api";

const api = await ApiPromise.create({
  ...getApiOptions(),
  ...getPublicProvider("root"),
});
```

- Use `api` instance to interact with node

```typescript
// query and display account data
const data = await api.query.system.account("0xE04CC55ebEE1cBCE552f250e85c57B70B2E2625b");
console.log(data.toHuman());
```

## TypeScript Support

See [`api-types`](https://github.com/futureversecom/trn-js-api/tree/main/packages/api-types) for more details

## API

### `function getApiOptions()`

Returns an `ApiOptions` object that contains necessary types, rpc methods to connect the Root Network

### `function getPublicProvider(network: NetworkName, useWsProvider?: boolean, useArchiveNode?: boolean)`

Returns a `provider` instance of either `WsProvider` or `HttpProvider` that connects to TRN mainnet `"root"` or testnet `"porcini"`

### `function getPublicProviderUrl(network: NetworkName, useWsProvider?: boolean, useArchiveNode?: boolean)`

Used by `getPublicProvider`, simply returns public URL for the provider

## Updating Metadata

To update the metadata for a newer version of the TRN runtime, run:

```bash
pnpm --filter=@therootnetwork/api-types update:meta
pnpm --filter=@therootnetwork/api-types generate:types
```

Then to update the test snapshot run:

```bash
pnpm test:snapshot
```

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