Package Exports
- shoonya-sdk
- shoonya-sdk/dist/index.cjs
- shoonya-sdk/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (shoonya-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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-sdkGetting 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...