/upstox-nodejs

Official NodeJS library for accessing Upstox APIs

Primary LanguageJavaScript

Upstox Node Js SDK for API v2

Introduction

The official Node.js client for communicating with the Upstox API.

Upstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection.

  • API version: v2
  • Build package: io.swagger.codegen.v3.generators.javascript.JavaScriptClientCodegen

This SDK is automatically generated by the Swagger Codegen project.

Documentation.

Upstox API Documentation

Installation

npm

npm install upstox-js-sdk --save

Examples

Sample Implementations can be found within /examples folder.

Getting Started

Please follow the installation instruction and execute the following JS code:

var UpstoxClient = require('upstox-js-sdk');
var defaultClient = UpstoxClient.ApiClient.instance;

// Configure OAuth2 access token for authorization: OAUTH2
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "YOUR ACCESS TOKEN"

var api = new UpstoxClient.ChargeApi()
var instrumentToken = "instrumentToken_example"; // {String} Key of the instrument
var quantity = 56; // {Number} Quantity with which the order is to be placed
var product = "product_example"; // {String} Product with which the order is to be placed
var transactionType = "transactionType_example"; // {String} Indicates whether its a BUY or SELL order
var price = 3.4; // {Number} Price with which the order is to be placed
var apiVersion = "apiVersion_example"; // {String} API Version Header

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.getBrokerage(instrumentToken, quantity, product, transactionType, price, apiVersion, callback);

Documentation for API Endpoints

All URIs are relative to https://api-v2.upstox.com

Class Method HTTP request Description
UpstoxClient.ChargeApi getBrokerage GET /charges/brokerage Brokerage details
UpstoxClient.HistoryApi getHistoricalCandleData GET /historical-candle/{instrumentKey}/{interval}/{to_date} Historical candle data
UpstoxClient.HistoryApi getHistoricalCandleData1 GET /historical-candle/{instrumentKey}/{interval}/{to_date}/{from_date} Historical candle data
UpstoxClient.HistoryApi getIntraDayCandleData GET /historical-candle/intraday/{instrumentKey}/{interval} Intra day candle data
UpstoxClient.LoginApi authorize GET /login/authorization/dialog Authorize API
UpstoxClient.LoginApi logout DELETE /logout Logout
UpstoxClient.LoginApi token POST /login/authorization/token Get token API
UpstoxClient.MarketQuoteApi getFullMarketQuote GET /market-quote/quotes Market quotes and instruments - Full market quotes
UpstoxClient.MarketQuoteApi getMarketQuoteOHLC GET /market-quote/ohlc Market quotes and instruments - OHLC quotes
UpstoxClient.MarketQuoteApi ltp GET /market-quote/ltp Market quotes and instruments - LTP quotes.
UpstoxClient.OrderApi cancelOrder DELETE /order/cancel Cancel order
UpstoxClient.OrderApi getOrderBook GET /order/retrieve-all Get order book
UpstoxClient.OrderApi getOrderDetails GET /order/history Get order details
UpstoxClient.OrderApi getTradeHistory GET /order/trades/get-trades-for-day Get trades
UpstoxClient.OrderApi getTradesByOrder GET /order/trades Get trades for order
UpstoxClient.OrderApi modifyOrder PUT /order/modify Modify order
UpstoxClient.OrderApi placeOrder POST /order/place Place order
UpstoxClient.PortfolioApi convertPositions PUT /portfolio/convert-position Convert Positions
UpstoxClient.PortfolioApi getHoldings GET /portfolio/long-term-holdings Get Holdings
UpstoxClient.PortfolioApi getPositions GET /portfolio/short-term-positions Get Positions
UpstoxClient.TradeProfitAndLossApi getProfitAndLossCharges GET /trade/profit-loss/charges Get profit and loss on trades
UpstoxClient.TradeProfitAndLossApi getTradeWiseProfitAndLossData GET /trade/profit-loss/data Get Trade-wise Profit and Loss Report Data
UpstoxClient.TradeProfitAndLossApi getTradeWiseProfitAndLossMetaData GET /trade/profit-loss/metadata Get profit and loss meta data on trades
UpstoxClient.UserApi getProfile GET /user/profile Get profile
UpstoxClient.UserApi getUserFundMargin GET /user/get-funds-and-margin Get User Fund And Margin
UpstoxClient.WebsocketApi getMarketDataFeed GET /feed/market-data-feed Market Data Feed
UpstoxClient.WebsocketApi getMarketDataFeedAuthorize GET /feed/market-data-feed/authorize Market Data Feed Authorize
UpstoxClient.WebsocketApi getPortfolioStreamFeed GET /feed/portfolio-stream-feed Portfolio Stream Feed
UpstoxClient.WebsocketApi getPortfolioStreamFeedAuthorize GET /feed/portfolio-stream-feed/authorize Portfolio Stream Feed Authorize

Documentation for Models