shoonya-sdk 0.5.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -2
- package/dist/{shoonya-sdk.cjs → index.cjs} +483 -419
- package/dist/index.d.cts +933 -0
- package/dist/index.d.ts +933 -0
- package/dist/{shoonya-sdk.js → index.js} +476 -414
- package/package.json +5 -7
- package/tsup.config.ts +1 -1
- package/dist/shoonya-sdk.d.cts +0 -522
- package/dist/shoonya-sdk.d.ts +0 -522
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
# Shoonya SDK
|
|
1
|
+
# Shoonya SDK
|
|
2
2
|
|
|
3
|
-
Wrapper around Shoonya API
|
|
3
|
+
Wrapper around Shoonya API
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
# bun
|
|
9
|
+
bun add shoonya-sdk
|
|
10
|
+
# npm
|
|
11
|
+
npm install shoonya-sdk
|
|
12
|
+
# yarn
|
|
13
|
+
yarn add shoonya-sdk
|
|
14
|
+
# pnpm
|
|
15
|
+
pnpm add shoonya-sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Getting Started
|
|
19
|
+
|
|
20
|
+
### Using both WebsocketClient and RestClient
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { RestClient, WebsocketClient } from "shoonya-sdk";
|
|
24
|
+
|
|
25
|
+
const restClient = new RestClient(credentials, { logging: true });
|
|
26
|
+
const wsClient = new WebsocketClient({ logging: true }); // No need to pass credential here
|
|
27
|
+
|
|
28
|
+
const userDetail = restClient.getUserDetails();
|
|
29
|
+
console.log(`Logged in as ${userDetail.actid}`);
|
|
30
|
+
|
|
31
|
+
wsClient.on("connected", () => {
|
|
32
|
+
wsClient.subscribe("NSE|26009"); // Bank Nifty
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
wsClient.on("priceUpdate", (data) => {
|
|
36
|
+
console.log(data);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
wsClient.connect();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Only using WebsocketClient
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { WebsocketClient } from "shoonya-sdk";
|
|
46
|
+
|
|
47
|
+
const wsClient = new WebsocketClient({
|
|
48
|
+
cred: {
|
|
49
|
+
// now you need to pass the credentials here
|
|
50
|
+
},
|
|
51
|
+
logging: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
wsClient.on("connected", () => {
|
|
55
|
+
wsClient.subscribe(["NSE|26009", "NSE|26000"]); // Bank Nifty and Nifty 50
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
wsClient.on("priceUpdate", (data) => {
|
|
59
|
+
console.log(data);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
wsClient.connect();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Features
|
|
66
|
+
|
|
67
|
+
- Auto Reconnect On Failures
|
|
68
|
+
- Auto Refresh Access Token When it is expired
|
|
69
|
+
- Sync Credentials and Tokens between Rest and WS Clients
|
|
70
|
+
- Reconnect with Shoonya WS at fixed time interval, which is configurable
|
|
71
|
+
- and more...
|