NodeJS
To install the OpenAlgo Node.js library, use npm:
npm install openalgoOpenAlgo Node.js Library Documentation
Get the OpenAlgo API Key
Make sure that your OpenAlgo Application is running. Login to the OpenAlgo Application with valid credentials and get the OpenAlgo API key.
For detailed function parameters, refer to the API Documentation.
Getting Started with OpenAlgo
First, import the OpenAlgo class from the library and initialize it with your API key:
import OpenAlgo from 'openalgo';
// Replace 'YOUR_API_KEY' with your actual API key
// Specify the host URL with your hosted domain or ngrok domain.
// If running locally in Windows then use the default host value.
const openalgo = new OpenAlgo('YOUR_API_KEY', 'http://127.0.0.1:5000');Check OpenAlgo Version
PlaceOrder Example
To place a new order:
Place Market Order Response
PlaceSmartOrder Example
To place a smart order considering the current position size:
Place Smart Market Order Response
BasketOrder Example
To place a new basket order:
Basket Order Response
SplitOrder Example
To place a new split order:
SplitOrder Response
ModifyOrder Example
To modify an existing order:
Modify Order Response
CancelOrder Example
To cancel an existing order:
Cancelorder Response
CancelAllOrder Example
To cancel all open orders and trigger pending orders:
Cancelallorder Response
ClosePosition Example
To close all open positions across various exchanges:
ClosePosition Response
OrderStatus Example
To get the current order status:
Orderstatus Response
OpenPosition Example
To get the current open position:
OpenPosition Response
Quotes Example
To get real-time quotes:
Quotes response
Depth Example
To get market depth data:
Depth Response
History Example
To get historical data:
History Response
Intervals Example
To get supported time intervals:
Intervals response
Symbol Example
To get symbol information:
Symbols Response
Search Example
Search Response
Expiry Example
Expiry Response
Funds Example
To get account funds information:
Funds Response
OrderBook Example
To get the order book:
OrderBook Response
TradeBook Example
To get the trade book:
TradeBook Response
PositionBook Example
To get the position book:
PositionBook Response
Holdings Example
To get holdings:
Holdings Response
Analyzer Status Example
Analyzer Status Response
Analyzer Toggle Example
Analyzer Toggle Response
LTP Data (Streaming Websocket)
Quotes (Streaming Websocket)
Depth (Streaming Websocket)
Please refer to the documentation and consult the API reference for details on optional parameters:
Last updated
Was this helpful?