JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 127
  • Score
    100M100P100Q78590F
  • License Apache-2.0

NodeJS SDK for Groww trading APIs

Package Exports

  • growwapi
  • growwapi/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 (growwapi) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

growwapi

NodeJS SDK for Groww trading APIs

npm version GitHub last commit

downloads GitHub issues

CI Status license

📝 Overview

growwapi is a NodeJS SDK for Groww trading APIs. The library provides functionality for trading on Groww including holdings management, margin calculations, order management, and position tracking.


🚀 Features

  • Authentication: Secure API access with API key and TOTP
  • Live Feed: Real-time data streaming for market prices
  • Historic Data: Access to historical market data
  • Holdings: Fetch user portfolio holdings
  • Instructions: CSV-based instrument details
  • Live Data: Current market data access
  • Margins: Retrieve margin details and calculate margins required for orders
  • Orders: Create, modify, cancel, and fetch order details
  • Positions: Fetch user positions and trading symbol details

⚙️ Installation

npm install growwapi

⚡ Quick Start

1. Environment Setup

Create a .env file in your project root:

GROWW_API_KEY=your_api_key
GROWW_API_SECRET=your_api_secret

Optional:

GROWW_API_BASE_URL=
GROWW_API_VERSION=
GROWW_FILECACHE_TTL=
GROWW_LIVE_FEED_MAX_RETRY_COUNT=
GROWW_LIVE_FEED_MAX_RETRY_DURATION=

2. Basic Usage

import { GrowwAPI } from 'growwapi';

const Groww = new GrowwAPI();

📚 Examples

After connecting and authenticating, you can explore detailed usage for each feature in the examples directory

Each example demonstrates real-world usage and best practices for the respective module.


📚 API Reference

Authentication (Auth)

  • Auth.generateToken(): Promise<AuthTokenResponse>
    Generates a new authentication token.
  • Auth.refreshToken(): Promise<AuthTokenResponse>
    Refreshes the current authentication token.

Live Feed (LiveFeed)

  • LiveFeed.connect(callback: (data) => void): void
    Establishes a WebSocket connection for real-time data.
  • LiveFeed.subscribe(instrumentId: string): void
    Subscribes to real-time data for a specific instrument.
  • LiveFeed.consume(subscription: string): void
    Starts consuming data from a subscription.
  • LiveFeed.disconnect(): void
    Disconnects from the WebSocket.

Live Data (LiveData)

  • LiveData.getQuote(params: GetQuoteParams): Promise<GetQuoteResponse>
    Fetches current quote for a trading symbol.
  • LiveData.getLTP(params: GetLTPParams): Promise<GetLTPResponse>
    Fetches last traded price for one or more symbols.
  • LiveData.getOHLC(params: GetOHLCParams): Promise<GetOHLCResponse>
    Fetches OHLC data for one or more symbols.

Historic Data (HistoricData)

  • HistoricData.get(params: HistoricDataParams): Promise<HistoricDataResponse>
    Fetches historical candle data for a trading symbol.

Instructions (Instructions)

  • Instructions.getInstructions(): Promise<InstructionsResponse>
    Fetches the full instructions CSV file.
  • Instructions.getFilteredInstructions(params: InstructionsTypeParams): Promise<InstructionsResponse>
    Fetches filtered instructions based on provided parameters.

Portfolio & Trading

Holdings (Holdings)

  • Holdings.list(): Promise<HoldingsResponse>
    Fetches user holdings.

Margins (Margins)

  • Margins.details(): Promise<MarginsResponse>
    Fetches margin details for the user.
  • Margins.requiredForOrder(params: MarginsRequiredParams): Promise<MarginsRequiredResponse>
    Calculates margins required for an order.

Orders (Orders)

  • Orders.create(params: CreateOrderParams): Promise<CreateOrderResponse>
    Creates a new order.
  • Orders.modify(params: ModifyOrderParams): Promise<ModifyOrderResponse>
    Modifies an existing order.
  • Orders.cancel(params: CancelOrderParams): Promise<CancelOrderResponse>
    Cancels an order.
  • Orders.getTrades(params: GetTradesParams): Promise<GetTradesResponse>
    Fetches trade details for an order.
  • Orders.status(params: OrderStatusParams): Promise<OrderStatusResponse>
    Fetches the status of an order.
  • Orders.statusByReference(params: OrderStatusByReferenceParams): Promise<OrderStatusResponse>
    Fetches the status of an order by reference ID.
  • Orders.getOrders(params: ListOrderParams): Promise<OrderResponse[]>
    Lists all orders.
  • Orders.details(params: OrderDetailsParams): Promise<OrderResponse>
    Fetches details of an order.

Positions (Positions)

  • Positions.user(params: BaseParams): Promise<PositionsResponse>
    Fetches user positions.
  • Positions.tradingSymbol(params: TradingSymbolParams): Promise<TradingSymbolResponse>
    Fetches details of a trading symbol.

Types

All request and response types are available in the types directory and are strongly typed for TypeScript.
See the types folder for details.


🛠️ Development

Scripts

  • npm run build: Builds the project.
  • npm run test: Runs tests.
  • npm run lint: Lints the code.
  • npm generate-exports: Generates exports for all types.

Testing

npm run test

Linting

npm run lint

🏗️ Architecture

  • GrowwAPI: Main class that initializes and provides access to all service modules
  • Resources: Independent modules for different API functionalities:
    • Auth, LiveFeed, HistoricData, Holdings, Instructions, LiveData, Margins, Orders, Positions

🤝 Contributing

  • Maintain strong typing for all methods and parameters
  • Follow resource-based module organization
  • Use camelCase for variables and methods
  • Document all public methods and parameters
  • Handle API errors consistently with descriptive messages
  • Validate environmental dependencies before API calls
  • Follow the established pattern for new resource modules

📄 License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.