@ganaka/sdk 1.6.0 → 1.7.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/dist/index.mjs CHANGED
@@ -8631,6 +8631,150 @@ async function runMinuteLoop({
8631
8631
  nextBoundaryDayJS = nextBoundaryDayJS.add(intervalMinutes, "minute");
8632
8632
  }
8633
8633
  }
8634
+ class GanakaClient {
8635
+ constructor(config2) {
8636
+ this.developerToken = config2?.developerToken || process.env.DEVELOPER_KEY || "";
8637
+ this.apiDomain = config2?.apiDomain || process.env.API_DOMAIN || "https://api.ganaka.live";
8638
+ if (!this.developerToken) {
8639
+ throw new Error(
8640
+ "Developer token not found. Please provide developerToken in constructor or set DEVELOPER_KEY environment variable."
8641
+ );
8642
+ }
8643
+ }
8644
+ /**
8645
+ * Fetch historical candles for a symbol.
8646
+ *
8647
+ * @param params - Query parameters for fetching candles
8648
+ * @param params.symbol - The symbol to fetch candles for
8649
+ * @param params.interval - The interval for candles (e.g., "1minute", "5minute", "1day")
8650
+ * @param params.start_datetime - Start datetime in IST string format (YYYY-MM-DDTHH:mm:ss)
8651
+ * @param params.end_datetime - End datetime in IST string format (YYYY-MM-DDTHH:mm:ss)
8652
+ * @returns Promise resolving to candle data
8653
+ */
8654
+ async fetchCandles(params) {
8655
+ const callback = fetchCandles({
8656
+ developerToken: this.developerToken,
8657
+ apiDomain: this.apiDomain,
8658
+ runId: null,
8659
+ currentTimestamp: "",
8660
+ currentTimezone: "Asia/Kolkata"
8661
+ });
8662
+ return callback(params);
8663
+ }
8664
+ /**
8665
+ * Fetch quote for a symbol at a specific datetime.
8666
+ *
8667
+ * @param params - Query parameters for fetching quote
8668
+ * @param params.symbol - The symbol to fetch quote for
8669
+ * @param params.datetime - Datetime in IST string format (YYYY-MM-DDTHH:mm:ss)
8670
+ * @returns Promise resolving to quote data or null
8671
+ */
8672
+ async fetchQuote(params) {
8673
+ const callback = fetchQuote({
8674
+ developerToken: this.developerToken,
8675
+ apiDomain: this.apiDomain,
8676
+ runId: null,
8677
+ currentTimestamp: "",
8678
+ currentTimezone: "Asia/Kolkata"
8679
+ });
8680
+ return callback(params);
8681
+ }
8682
+ /**
8683
+ * Fetch quote timeline for a symbol.
8684
+ * Given a symbol and an end_datetime, returns the quote timeline for the given date.
8685
+ *
8686
+ * @param symbol - The symbol to fetch quote timeline for
8687
+ * @param end_datetime - End datetime in IST string format (YYYY-MM-DDTHH:mm:ss)
8688
+ * @returns Promise resolving to quote timeline data
8689
+ */
8690
+ async fetchQuoteTimeline(symbol, end_datetime) {
8691
+ const callback = fetchQuoteTimeline({
8692
+ developerToken: this.developerToken,
8693
+ apiDomain: this.apiDomain,
8694
+ runId: null,
8695
+ currentTimestamp: "",
8696
+ currentTimezone: "Asia/Kolkata"
8697
+ });
8698
+ return callback(symbol, end_datetime);
8699
+ }
8700
+ /**
8701
+ * Fetch NIFTY quote at a specific datetime.
8702
+ *
8703
+ * @param params - Query parameters for fetching NIFTY quote
8704
+ * @param params.datetime - Datetime in IST string format (YYYY-MM-DDTHH:mm:ss)
8705
+ * @returns Promise resolving to NIFTY quote data or null
8706
+ */
8707
+ async fetchNiftyQuote(params) {
8708
+ const callback = fetchNiftyQuote({
8709
+ developerToken: this.developerToken,
8710
+ apiDomain: this.apiDomain,
8711
+ runId: null,
8712
+ currentTimestamp: "",
8713
+ currentTimezone: "Asia/Kolkata"
8714
+ });
8715
+ return callback(params);
8716
+ }
8717
+ /**
8718
+ * Fetch NIFTY quote timeline.
8719
+ * Given an end_datetime, returns the NIFTY quote timeline for the given date.
8720
+ *
8721
+ * @param end_datetime - End datetime in IST string format (YYYY-MM-DDTHH:mm:ss)
8722
+ * @returns Promise resolving to NIFTY quote timeline data
8723
+ */
8724
+ async fetchNiftyQuoteTimeline(end_datetime) {
8725
+ const callback = fetchNiftyQuoteTimeline({
8726
+ developerToken: this.developerToken,
8727
+ apiDomain: this.apiDomain,
8728
+ runId: null,
8729
+ currentTimestamp: "",
8730
+ currentTimezone: "Asia/Kolkata"
8731
+ });
8732
+ return callback(end_datetime);
8733
+ }
8734
+ /**
8735
+ * Fetch shortlist for a specific type and datetime.
8736
+ *
8737
+ * @param queryParams - Query parameters for fetching shortlist
8738
+ * @param queryParams.type - The type of shortlist (e.g., "top-gainers", "top-losers")
8739
+ * @param queryParams.datetime - Datetime in IST string format (YYYY-MM-DDTHH:mm:ss)
8740
+ * @returns Promise resolving to shortlist data or null
8741
+ */
8742
+ async fetchShortlist(queryParams) {
8743
+ const callback = fetchShortlist({
8744
+ developerToken: this.developerToken,
8745
+ apiDomain: this.apiDomain,
8746
+ runId: null,
8747
+ currentTimestamp: "",
8748
+ currentTimezone: "Asia/Kolkata"
8749
+ });
8750
+ return callback(queryParams);
8751
+ }
8752
+ /**
8753
+ * Fetch shortlist persistence.
8754
+ * Given a shortlist type and a start and end datetime,
8755
+ * returns the list of instruments that appeared in the shortlist during the time range
8756
+ * in descending order of appearance count.
8757
+ *
8758
+ * This helps identify the stocks that have been consistently appearing in the shortlist
8759
+ * over a given period of time.
8760
+ *
8761
+ * @param queryParams - Query parameters for fetching shortlist persistence
8762
+ * @param queryParams.type - The type of shortlist (e.g., "top-gainers", "top-losers")
8763
+ * @param queryParams.start_datetime - Start datetime in IST string format (YYYY-MM-DDTHH:mm:ss)
8764
+ * @param queryParams.end_datetime - End datetime in IST string format (YYYY-MM-DDTHH:mm:ss)
8765
+ * @returns Promise resolving to shortlist persistence data or null
8766
+ */
8767
+ async fetchShortlistPersistence(queryParams) {
8768
+ const callback = fetchShortlistPersistence({
8769
+ developerToken: this.developerToken,
8770
+ apiDomain: this.apiDomain,
8771
+ runId: null,
8772
+ currentTimestamp: "",
8773
+ currentTimezone: "Asia/Kolkata"
8774
+ });
8775
+ return callback(queryParams);
8776
+ }
8777
+ }
8634
8778
  dotenv.config();
8635
8779
  dayjs.extend(utc);
8636
8780
  dayjs.extend(timezone);
@@ -8767,6 +8911,7 @@ async function ganaka({
8767
8911
  }
8768
8912
  }
8769
8913
  export {
8914
+ GanakaClient,
8770
8915
  ganaka,
8771
8916
  S as growwQuotePayloadSchema,
8772
8917
  a as growwQuoteSchema