shoonya-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

Shoonya SDK

Wrapper around Shoonya API

Installation

# bun
bun add shoonya-sdk
# npm
npm install shoonya-sdk
# yarn
yarn add shoonya-sdk
# pnpm
pnpm add shoonya-sdk

Getting Started

Using both WebsocketClient and RestClient

import { RestClient, WebsocketClient } from "shoonya-sdk";

const restClient = new RestClient(credentials, { logging: true });
const wsClient = new WebsocketClient({ logging: true }); // No need to pass credential here

const userDetail = await restClient.getUserDetails();
console.log(`Logged in as ${userDetail.actid}`);

wsClient.on("connected", () => {
  wsClient.subscribe("NSE|26009"); // Bank Nifty
});

wsClient.on("priceUpdate", (data) => {
  console.log(data);
});

wsClient.connect();

Only using WebsocketClient

import { WebsocketClient } from "shoonya-sdk";

const wsClient = new WebsocketClient({
  cred: {
    // now you need to pass the credentials here
  },
  logging: true,
});

wsClient.on("connected", () => {
  wsClient.subscribe(["NSE|26009", "NSE|26000"]); // Bank Nifty and Nifty 50
});

wsClient.on("priceUpdate", (data) => {
  console.log(data);
});

wsClient.connect();

Features

  • Auto Reconnect On Failures
  • Auto Refresh Access Token When it is expired
  • Sync Credentials and Tokens between Rest and WS Clients
  • Reconnect with Shoonya WS at fixed time interval, which is configurable
  • Configurable heartbeat timer to keep connection alive
  • and more...

Readme

Keywords

Package Sidebar

Install

npm i shoonya-sdk

Weekly Downloads

71

Version

1.3.1

License

MIT

Unpacked Size

116 kB

Total Files

7

Last publish

Collaborators

  • cryogon