Wrapper around Shoonya API
# bun
bun add shoonya-sdk
# npm
npm install shoonya-sdk
# yarn
yarn add shoonya-sdk
# pnpm
pnpm add shoonya-sdk
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();
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();
- 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...