# @redstone-finance/sdk

> Typescript/Javascript SDK for interacting with the RedStone ecosystem. Below a couple of basic use cases.

Latest version **1.0.0** (published 2026-08-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @redstone-finance/sdk
pnpm add @redstone-finance/sdk
yarn add @redstone-finance/sdk
bun add @redstone-finance/sdk
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-08-26 |
| First published | 2023-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 411.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | redstone-finance |

## Links

- npm: https://www.npmjs.com/package/@redstone-finance/sdk
- npm.io page: https://npm.io/package/@redstone-finance/sdk

## Dependencies (6)

- [zod](https://npm.io/package/zod.md) ^4.1.12
- [axios](https://npm.io/package/axios.md) ^1.19
- [lodash](https://npm.io/package/lodash.md) ^4.17.23
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.195
- [@redstone-finance/utils](https://npm.io/package/@redstone-finance/utils.md) 1.0.0
- [@redstone-finance/protocol](https://npm.io/package/@redstone-finance/protocol.md) 1.0.0

## Recent versions

- 1.0.0 (latest) — 2026-08-26
- 0.9.0 — 2025-08-11
- 0.8.0 — 2025-02-19
- 0.7.5 — 2025-02-05
- 0.7.4 — 2025-02-04
- 0.7.3 — 2024-12-11
- 0.7.2 — 2024-11-29
- 0.7.1 — 2024-11-26
- 0.7.0 — 2024-11-26
- 0.6.2 — 2024-09-16
- 0.6.1 — 2024-07-24
- 0.6.0 — 2024-07-18
- 0.5.4 — 2024-06-06
- 0.5.3 — 2024-06-06
- 0.5.2 — 2024-06-06
- … 10 more at https://npm.io/package/@redstone-finance/sdk/versions

## README

# RedStone JS SDK

Typescript/Javascript SDK for interacting with the RedStone ecosystem. Below a couple of basic use cases.

## Fetch data packages

The most common use case is to fetch data packages for off-chain consumption. If you want to consume RedStone data packages on-chain consider using @redstone-finance/evm-connector library.

We provide a single method that can be used to fetch and validate packages

```typescript
import {
  requestDataPackages,
  getSignersForDataServiceId,
  getOracleRegistryStateSync,
} from "@redstone-finance/sdk";

// fetch data packages from RedStone DDL based on provided fetch configuration.
const dataPackages = await requestDataPackages({
  // for production environment most of the time "redstone-primary-prod" is appropriate
  dataServiceId: "redstone-primary-prod",
  // array of tokens to fetch
  dataPackagesIds: ["BTC", "ETH"],
  // ensure minimum number of signers for each token
  // - 'uniqueSignersCount' packages closest to median of all fetched packages are returned
  // - throws if there are less signers for any token
  uniqueSignersCount: 2,
  // (optional, default: 500) wait for responses from all the gateways for this time, then wait for at least one response and return the newest fetched packages (does not apply if 'historicalTimestamp' is provided)
  waitForAllGatewaysTimeMs: 1000,
  // (optional, default: no filter) filter out old packages
  maxTimestampDeviationMS: 60 * 1000,
  // (optional, default: no filter) accept packages only from specific signers, by default signatures are not verified. RedStone gateway won't return packages not signed by RedStone nodes, but you may still want to use this filter if you use your own gateway or want higher level of security (e.g. stay immune to man-in-the-middle attacks)
  authorizedSigners: getSignersForDataServiceId("redstone-primary-prod"),
  // (optional, default: false) do not throw error in case of missing or filtered-out token
  ignoreMissingFeed: true,
});
```

## Validate package signature

In the case when you want to verify package signature on your own it you can use the following code snippet

```typescript
import { recoverSignerAddress } from "@redstone-finance/protocol";
import { getSignersForDataServiceId } from "@redstone-finance/sdk";

// well-known RedStone primary node addresses
// you can pass this list to requestDataPackages method above to perform validation automatically
const redstonePrimaryNodesAddresses = getSignersForDataServiceId("redstone-primary-prod");

const signerAddress = recoverSignerAddress(dataPackage);
if (redstonePrimaryNodesAddresses.includes(signerAddress)) {
  // package is signed by RedStone primary node
} else {
  // package is corrupted or not signed by RedStone primary node
}
```

## Verify that data package was signed by RedStone

If you recovered signer address of the package you can verify if it is RedStone address.

```typescript
import { getDataServiceIdForSigner } from "@redstone-finance/sdk";

let dataServiceId: string;
try {
  const oracleRegistry = await getOracleRegistryState();
  dataServiceId = getDataServiceIdForSigner(oracleRegistry, address);
} catch (e) {
  // address not known to RedStone, be cautious
}
```

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