0.0.4 • Published 11 months ago

upstoxjsclient v0.0.4

Weekly downloads
-
License
Unlicense
Repository
-
Last release
11 months ago

upstox_developer_api

UpstoxDeveloperApi - JavaScript client for upstox_developer_api Build your App on the Upstox platform Banner(https://api-v2.upstox.com/api-docs/images/banner.jpg \"banner\") # Introduction 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. All requests are over HTTPS and the requests are sent with the content-type ‘application/json’. Developers have the option of choosing the response type as JSON or CSV for a few API calls. To be able to use these APIs you need to create an App in the Developer Console and generate your apiKey and apiSecret. You can use a redirect URL which will be called after the login flow. If you are a trader, you can directly create apps from Upstox mobile app or the desktop platform itself from Apps sections inside the Account Tab. Head over to <a href=\"http://account.upstox.com/developer/apps\" target=\"_blank\">account.upstox.com/developer/apps. If you are a business looking to integrate Upstox APIs, reach out to us and we will get a custom app created for you in no time. It is highly recommended that you do not embed the apiSecret in your frontend app. Create a remote backend which does the handshake on behalf of the frontend app. Marking the apiSecret in the frontend app will make your app vulnerable to threats and potential issues. This SDK is automatically generated by the Swagger Codegen project:

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

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install upstox_developer_api --save

git

If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:

    npm install GIT_USER_ID/GIT_REPO_ID --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

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

var UpstoxDeveloperApi = require('upstox_developer_api');
var defaultClient = UpstoxDeveloperApi.ApiClient.instance;

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

var api = new UpstoxDeveloperApi.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

ClassMethodHTTP requestDescription
UpstoxDeveloperApi.ChargeApigetBrokerageGET /charges/brokerageBrokerage details
UpstoxDeveloperApi.HistoryApigetHistoricalCandleDataGET /historical-candle/{instrumentKey}/{interval}/{to_date}Historical candle data
UpstoxDeveloperApi.HistoryApigetHistoricalCandleData1GET /historical-candle/{instrumentKey}/{interval}/{to_date}/{from_date}Historical candle data
UpstoxDeveloperApi.HistoryApigetIntraDayCandleDataGET /historical-candle/intraday/{instrumentKey}/{interval}Intra day candle data
UpstoxDeveloperApi.LoginApiauthorizeGET /login/authorization/dialogAuthorize API
UpstoxDeveloperApi.LoginApilogoutDELETE /logoutLogout
UpstoxDeveloperApi.LoginApitokenPOST /login/authorization/tokenGet token API
UpstoxDeveloperApi.MarketQuoteApigetFullMarketQuoteGET /market-quote/quotesMarket quotes and instruments - Full market quotes
UpstoxDeveloperApi.MarketQuoteApigetMarketQuoteOHLCGET /market-quote/ohlcMarket quotes and instruments - OHLC quotes
UpstoxDeveloperApi.MarketQuoteApiltpGET /market-quote/ltpMarket quotes and instruments - LTP quotes.
UpstoxDeveloperApi.OrderApicancelOrderDELETE /order/cancelCancel order
UpstoxDeveloperApi.OrderApigetOrderBookGET /order/retrieve-allGet order book
UpstoxDeveloperApi.OrderApigetOrderDetailsGET /order/historyGet order details
UpstoxDeveloperApi.OrderApigetTradeHistoryGET /order/trades/get-trades-for-dayGet trades
UpstoxDeveloperApi.OrderApigetTradesByOrderGET /order/tradesGet trades for order
UpstoxDeveloperApi.OrderApimodifyOrderPUT /order/modifyModify order
UpstoxDeveloperApi.OrderApiplaceOrderPOST /order/placePlace order
UpstoxDeveloperApi.PortfolioApiconvertPositionsPUT /portfolio/convert-positionConvert Positions
UpstoxDeveloperApi.PortfolioApigetHoldingsGET /portfolio/long-term-holdingsGet Holdings
UpstoxDeveloperApi.PortfolioApigetPositionsGET /portfolio/short-term-positionsGet Positions
UpstoxDeveloperApi.TradeProfitAndLossApigetProfitAndLossChargesGET /trade/profit-loss/chargesGet profit and loss on trades
UpstoxDeveloperApi.TradeProfitAndLossApigetTradeWiseProfitAndLossDataGET /trade/profit-loss/dataGet Trade-wise Profit and Loss Report Data
UpstoxDeveloperApi.TradeProfitAndLossApigetTradeWiseProfitAndLossMetaDataGET /trade/profit-loss/metadataGet profit and loss meta data on trades
UpstoxDeveloperApi.UserApigetProfileGET /user/profileGet profile
UpstoxDeveloperApi.UserApigetUserFundMarginGET /user/get-funds-and-marginGet User Fund And Margin
UpstoxDeveloperApi.WebsocketApigetMarketDataFeedGET /feed/market-data-feedMarket Data Feed
UpstoxDeveloperApi.WebsocketApigetMarketDataFeedAuthorizeGET /feed/market-data-feed/authorizeMarket Data Feed Authorize
UpstoxDeveloperApi.WebsocketApigetPortfolioStreamFeedGET /feed/portfolio-stream-feedPortfolio Stream Feed
UpstoxDeveloperApi.WebsocketApigetPortfolioStreamFeedAuthorizeGET /feed/portfolio-stream-feed/authorizePortfolio Stream Feed Authorize

Documentation for Models

Documentation for Authorization

OAUTH2

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago