laplace-api 4.3.0 → 4.3.2
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 +15 -2
- package/package.json +1 -1
- package/src/client/live-price.ts +20 -6
package/README.md
CHANGED
|
@@ -289,16 +289,25 @@ const results = await client.search(
|
|
|
289
289
|
### WebSocket Client
|
|
290
290
|
|
|
291
291
|
```typescript
|
|
292
|
+
// Server Side
|
|
293
|
+
// Initialize LivePriceClient for server side use
|
|
294
|
+
const livePriceClient = new LivePriceClient(config, logger);
|
|
295
|
+
|
|
296
|
+
// Retrieve a websocket connection URL for the client, pass the URL to the client
|
|
297
|
+
const wsURL = await livePriceClient.getClientWebsocketUrl('external-user-id', [LivePriceFeed.LiveBist])
|
|
298
|
+
|
|
299
|
+
// Client Side
|
|
300
|
+
// Client side retrieves the websocket connection URL from the server as wsURL
|
|
292
301
|
// Create WebSocket client for real-time data
|
|
293
302
|
const webSocketClient = new LivePriceWebSocketClient();
|
|
294
303
|
|
|
295
304
|
// Connect to WebSocket
|
|
296
|
-
await webSocketClient.connect(
|
|
305
|
+
await webSocketClient.connect(wsURL);
|
|
297
306
|
|
|
298
307
|
// Subscribe to live price feeds
|
|
299
308
|
const unsubscribe = webSocketClient.subscribe(
|
|
300
309
|
["THYAO", "GARAN"],
|
|
301
|
-
|
|
310
|
+
LivePriceFeed.LiveBist,
|
|
302
311
|
(data) => {
|
|
303
312
|
console.log("Received live data:", data);
|
|
304
313
|
}
|
|
@@ -306,6 +315,10 @@ const unsubscribe = webSocketClient.subscribe(
|
|
|
306
315
|
|
|
307
316
|
// Close connection
|
|
308
317
|
await webSocketClient.close();
|
|
318
|
+
|
|
319
|
+
// Server Side
|
|
320
|
+
// Use livePriceClient.getWebsocketUsageForMonth for getting a report on websocket client usage
|
|
321
|
+
const usage = await livePriceClient.getWebsocketUsageForMonth('8', '2025', LivePriceFeed.LiveBist);
|
|
309
322
|
```
|
|
310
323
|
|
|
311
324
|
### Capital Increase Client
|
package/package.json
CHANGED
package/src/client/live-price.ts
CHANGED
|
@@ -61,6 +61,12 @@ interface WebSocketUrlResponse {
|
|
|
61
61
|
url: string;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
interface WebSocketUsageResponse {
|
|
65
|
+
externalUserId: string;
|
|
66
|
+
firstConnectionTime: Date;
|
|
67
|
+
uniqueDeviceCount: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
64
70
|
interface WebSocketUrlParams {
|
|
65
71
|
externalUserId: string;
|
|
66
72
|
feeds: LivePriceFeed[];
|
|
@@ -278,13 +284,21 @@ export class LivePriceClient extends Client {
|
|
|
278
284
|
return response.url;
|
|
279
285
|
}
|
|
280
286
|
|
|
281
|
-
async
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
287
|
+
async getWebsocketUsageForMonth(
|
|
288
|
+
month: string,
|
|
289
|
+
year: string,
|
|
290
|
+
feedType: LivePriceFeed,
|
|
291
|
+
): Promise<WebSocketUsageResponse[]> {
|
|
292
|
+
const url = new URL(`${this["baseUrl"]}/api/v1/ws/report`);
|
|
293
|
+
url.searchParams.append("month", month);
|
|
294
|
+
url.searchParams.append("year", year);
|
|
295
|
+
url.searchParams.append("feedType", feedType);
|
|
296
|
+
|
|
297
|
+
const response = await this.sendRequest<WebSocketUsageResponse[]>({
|
|
298
|
+
method: "GET",
|
|
286
299
|
url: url.toString(),
|
|
287
|
-
data: params,
|
|
288
300
|
});
|
|
301
|
+
|
|
302
|
+
return response;
|
|
289
303
|
}
|
|
290
304
|
}
|