# leo-sdk

> Load data onto the LEO Platform

Latest version **7.1.21** (published 2026-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install leo-sdk
pnpm add leo-sdk
yarn add leo-sdk
bun add leo-sdk
```

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 7.1.21 |
| Published | 2026-06-12 |
| First published | 2017-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 20 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10 |
| Author | LEO Enterprises |
| Maintainers | leoinsights, jgrantr, czirker, elsmob, jhunsaker, zirkerc, francislewis |

## Links

- npm: https://www.npmjs.com/package/leo-sdk
- Repository: https://github.com/LeoPlatform/Nodejs
- Homepage: https://leoplatform.io
- Issues: https://github.com/LeoPlatform/Nodejs/issues
- npm.io page: https://npm.io/package/leo-sdk

## Dependencies (20)

- [ini](https://npm.io/package/ini.md) 2.0.0
- [pump](https://npm.io/package/pump.md) 3.0.0
- [uuid](https://npm.io/package/uuid.md) 8.3.2
- [async](https://npm.io/package/async.md) 2.6.4
- [extend](https://npm.io/package/extend.md) 3.0.2
- [lodash](https://npm.io/package/lodash.md) 4.18.1
- [moment](https://npm.io/package/moment.md) 2.29.4
- [split2](https://npm.io/package/split2.md) 3.1.1
- [backoff](https://npm.io/package/backoff.md) 2.5.0
- [pumpify](https://npm.io/package/pumpify.md) 1.5.1
- [fast-csv](https://npm.io/package/fast-csv.md) 4.3.6
- [through2](https://npm.io/package/through2.md) 3.0.1
- [fast-json](https://npm.io/package/fast-json.md) ^3.0.0
- [leo-config](https://npm.io/package/leo-config.md) 1.1.0
- [leo-logger](https://npm.io/package/leo-logger.md) 1.0.7
- [big-integer](https://npm.io/package/big-integer.md) ^1.6.51
- [event-stream](https://npm.io/package/event-stream.md) 4.0.1
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2
- [readable-stream](https://npm.io/package/readable-stream.md) 3.4.0
- [flush-write-stream](https://npm.io/package/flush-write-stream.md) 2.0.0

## Recent versions

- 7.1.21 (latest) — 2026-06-12
- 6.0.26-alpha (alpha) — 2024-02-01
- 7.0.2-alphav7 (alphav7) — 2024-01-16
- 5.0.34-latest-v5 (latest-v5) — 2023-12-04
- 6.0.17-rc.2 (rc.2) — 2023-07-31
- 5.0.31-latestv5 (latestv5) — 2023-07-31
- 6.0.17-rc (rc) — 2023-07-07
- 5.0.25-image-service (image-service) — 2022-11-23
- 6.0.12-beta (beta) — 2022-09-08
- 2.3.0-entrata-109-g5f567bc (entrata) — 2019-05-07
- 2.3.0-109-g5f567bc (test) — 2019-05-07
- 7.1.20 — 2026-04-02
- 7.1.19 — 2026-04-02
- 7.1.18 — 2026-03-14
- 7.1.17 — 2026-03-13
- … 199 more at https://npm.io/package/leo-sdk/versions

## README

A Node/Typescript SDK that pushes data to and pulls data from an instance of an RStreams bus.

Full documentation and getting started guide here: rstreams-site-url/rstreams-node-sdk/

For this SDK API documentation, get started with the [RStreamsSdk](classes/index.RStreamsSdk.html).

## Put

Send events one at a time to an instance of the RStreams bus.

[Put Operation documentation](rstreams-site-url/rstreams-node-sdk/sdk-apis/standalone-ops/put/)

```typescript
import { ConfigurationResources, RStreamsSdk } from "leo-sdk";
import { PersonRaw, PersonRawResults } from "../lib/types";
import axios from "axios";

async function main() {
  const rsdk: RStreamsSdk  = new RStreamsSdk();
  const person = await getRandomPerson();
  await rsdk.putEvent('rstreams-example.load-people', 'rstreams-example.people', person);
}

async function getRandomPerson(): Promise<PersonRaw> {
  const NUM_EVENTS = 1;
  const url = `https://randomuser.me/api/?results=${NUM_EVENTS}&exc=login,registered,phone,cell,picture,id&noinfo`;
  const {data, status} = await axios.get<PersonRawResults>(url);
  
  if (status !== 200) {
    throw new Error('Unable to get randomPeople from https://randomuser.me API: ' + status);
  }
  
  console.log('Person: ' + data.results[0].name.first + ' ' + data.results[0].name.last);

  return data.results[0];
}

(async () => {
  await main();
})()
```

## Enrich

Read events from one queue, modify them and send them on to another queue of the RStreams bus.

[Enrich Operation documentation](rstreams-site-url/rstreams-node-sdk/sdk-apis/standalone-ops/enrich/)

```typescript
import { EnrichOptions,  RStreamsSdk } from "leo-sdk";
import { Person, PersonRaw } from "../lib/types";
import axios from "axios";

async function main() {
  const rsdk: RStreamsSdk  = new RStreamsSdk();
  const opts: EnrichOptions<PersonRaw, Person>  = {
    id: 'rstreams-example.people-to-peopleplus',
    inQueue: 'rstreams-example.people',
    outQueue: 'rstreams-example.peopleplus',
    start: 'z/2022/04/20',
    config: {
      limit: 2
    },
    transform: async (person: PersonRaw) => {
      const p: Person = translate(person);
      await addCountryCode(p);
      return p;
    }
  };

  await rsdk.enrichEvents<PersonRaw, Person>(opts);
}

interface CountryCode {cca2: string;}

/**
 * @param person The person to add addr.countryCode to by calling a public API to
 *               turn a country name in a 2 digit country code (iso cca2)
 */
 async function addCountryCode(person: Person): Promise<void> {
    const url = `https://restcountries.com/v3.1/name/${person.addr.country}?fullText=true&fields=cca2`;    
    const cc: CountryCode = await axios.get(url);
    person.addr.countryCode = cc.cca2;
  }

/**
 * @param p The type from the public API we want to modify
 * @returns The new type that is flatter and gets rid of some attributes don't need
 */
function translate(p: PersonRaw): Person {
  return {
    gender: p.gender,
    firstName: p.name.first,
    lastName: p.name.last,
    email: p.email,
    birthDate: p.dob.date,
    nationality: p.nat,
    addr: {
      addr1: p.location.street.number + ' ' + p.location.street.name,
      city: p.location.city, 
      state: p.location.state,
      country: p.location.country,
      postcode: p.location.postcode,
      longitude: p.location.coordinates.longitude,
      latitude: p.location.coordinates.latitude,
      tzOffset: p.location.timezone.offset,
      tzDesc: p.location.timezone.description
    }
  }
}

(async () => {
  await main();
})()
```

## Offload

Stream data down from an RStreams bus queue at scale, optionally modify it and send it to another source such as a database or file.

[Offload Operation documentation](rstreams-site-url/rstreams-node-sdk/sdk-apis/standalone-ops/offload/)

```typescript
import { OffloadOptions,  RStreamsSdk } from "leo-sdk";
import { Person } from "../lib/types";
import axios, { AxiosResponse } from "axios";

async function main() {
  const rsdk: RStreamsSdk  = new RStreamsSdk();
  const opts: OffloadOptions<Person>  = {
    id: 'rstreams-example.offload-one-peopleplus',
    inQueue: 'rstreams-example.people',
    start: 'z/2022/04/20',
    limit: 2,
    transform: async (person: Person) => {
        await savePerson(person);
        return true;        
    }
  };

  await rsdk.offloadEvents<Person>(opts);
}

interface PostResponse {
    success: boolean;
}

/**
 * @param person Save the person to another system.
 */
async function savePerson(person: Person): Promise<void> {
  const url = `https://run.mocky.io/v3/83997150-ab13-43da-9fb9-66051ba06c10?mocky-delay=500ms`;    
  const {data, status}: AxiosResponse<PostResponse, any> = await axios.post<PostResponse>(url, person);
  if (status !== 200 || !data || data.success !== true) {
    throw new Error('Saving person to external system failed');
  }
}

(async () => {
  await main();
})()
```

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