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
Features
- Holdings: Fetch user holdings.
- 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
Install the package using npm:
npm install growwapiUsage
Setup
Create a .env file in your project root and add the following environment variables:
GROWW_API_KEY=your_api_key
GROWW_API_SECRET=your_api_secretExample
import { GrowwAPI } from 'growwapi';
const client = new GrowwAPI();
// Fetch user holdings
const holdings = await client.holdings.list();
console.log(holdings);
// Create an order
client.orders.create({
exchange: Exchange.NSE,
orderType: OrderType.Limit,
product: Product.CNC,
quantity: 10,
segment: Segment.Cash,
tradingSymbol: 'RELIANCE',
transactionType: TransactionType.Buy,
validity: Validity.Day,
price: 2500,
}).then(console.log).catch(console.error);API Reference
Holdings
Holdings.list()
Fetches user holdings.
Margins
Margins.details()
Fetches margin details for the user.
Margins.requiredForOrder(params: RequiredForOrderParams)
Calculates margins required for an order.
Parameters:
params: RequiredForOrderParams- The parameters for margin calculation.
Orders
Orders.create(params: CreateOrderParams)
Creates a new order.
Parameters:
params: CreateOrderParams- The parameters for creating an order.
Orders.modify(params: ModifyOrderParams)
Modifies an existing order.
Parameters:
params: ModifyOrderParams- The parameters for modifying an order.
Orders.cancel(params: CancelOrderParams)
Cancels an order.
Parameters:
params: CancelOrderParams- The parameters for canceling an order.
Orders.getTrades(params: GetTradesParams)
Fetches trade details for an order.
Parameters:
params: GetTradesParams- The parameters for fetching trade details.
Orders.status(params: OrderStatusParams)
Fetches the status of an order.
Parameters:
params: OrderStatusParams- The parameters for fetching order status.
Orders.statusByReferenceID(params: OrderStatusByReferenceParams)
Fetches the status of an order by reference ID.
Parameters:
params: OrderStatusByReferenceParams- The parameters for fetching order status by reference ID.
Orders.list(params: ListOrderParams)
Lists all orders.
Parameters:
params: ListOrderParams- The parameters for listing orders.
Orders.get(params: GetOrderParams)
Fetches details of an order.
Parameters:
params: GetOrderParams- The parameters for fetching order details.
Positions
Positions.user(params: UserParams)
Fetches user positions.
Parameters:
params: UserParams- The parameters for fetching user positions.
Positions.tradingSymbol(params: TradingSymbolParams)
Fetches details of a trading symbol.
Parameters:
params: TradingSymbolParams- The parameters for fetching trading symbol details.
Development
Scripts
npm run build: Builds the project.npm run dev: Runs the project in development mode.npm run test: Runs tests.npm run lint: Lints the code.
Testing
Run tests using:
npm run testLinting
Lint the code using:
npm run lintLicense
This project is licensed under the Apache License 2.0. See the LICENSE file for details.