upstoxjsclient
v0.0.4
Published
Build_your_App_on_the_Upstox_platform_Banner_httpsapi_v2_upstox_comapi_docsimagesbanner_jpg_banner_IntroductionUpstox_API_is_a_set_of_rest_APIs_that_provide_data_required_to_build_a_complete_investment_and_trading_platform__Execute_orders_in_real_time_man
Downloads
1
Readme
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
Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- UpstoxDeveloperApi.ChargeApi | getBrokerage | GET /charges/brokerage | Brokerage details UpstoxDeveloperApi.HistoryApi | getHistoricalCandleData | GET /historical-candle/{instrumentKey}/{interval}/{to_date} | Historical candle data UpstoxDeveloperApi.HistoryApi | getHistoricalCandleData1 | GET /historical-candle/{instrumentKey}/{interval}/{to_date}/{from_date} | Historical candle data UpstoxDeveloperApi.HistoryApi | getIntraDayCandleData | GET /historical-candle/intraday/{instrumentKey}/{interval} | Intra day candle data UpstoxDeveloperApi.LoginApi | authorize | GET /login/authorization/dialog | Authorize API UpstoxDeveloperApi.LoginApi | logout | DELETE /logout | Logout UpstoxDeveloperApi.LoginApi | token | POST /login/authorization/token | Get token API UpstoxDeveloperApi.MarketQuoteApi | getFullMarketQuote | GET /market-quote/quotes | Market quotes and instruments - Full market quotes UpstoxDeveloperApi.MarketQuoteApi | getMarketQuoteOHLC | GET /market-quote/ohlc | Market quotes and instruments - OHLC quotes UpstoxDeveloperApi.MarketQuoteApi | ltp | GET /market-quote/ltp | Market quotes and instruments - LTP quotes. UpstoxDeveloperApi.OrderApi | cancelOrder | DELETE /order/cancel | Cancel order UpstoxDeveloperApi.OrderApi | getOrderBook | GET /order/retrieve-all | Get order book UpstoxDeveloperApi.OrderApi | getOrderDetails | GET /order/history | Get order details UpstoxDeveloperApi.OrderApi | getTradeHistory | GET /order/trades/get-trades-for-day | Get trades UpstoxDeveloperApi.OrderApi | getTradesByOrder | GET /order/trades | Get trades for order UpstoxDeveloperApi.OrderApi | modifyOrder | PUT /order/modify | Modify order UpstoxDeveloperApi.OrderApi | placeOrder | POST /order/place | Place order UpstoxDeveloperApi.PortfolioApi | convertPositions | PUT /portfolio/convert-position | Convert Positions UpstoxDeveloperApi.PortfolioApi | getHoldings | GET /portfolio/long-term-holdings | Get Holdings UpstoxDeveloperApi.PortfolioApi | getPositions | GET /portfolio/short-term-positions | Get Positions UpstoxDeveloperApi.TradeProfitAndLossApi | getProfitAndLossCharges | GET /trade/profit-loss/charges | Get profit and loss on trades UpstoxDeveloperApi.TradeProfitAndLossApi | getTradeWiseProfitAndLossData | GET /trade/profit-loss/data | Get Trade-wise Profit and Loss Report Data UpstoxDeveloperApi.TradeProfitAndLossApi | getTradeWiseProfitAndLossMetaData | GET /trade/profit-loss/metadata | Get profit and loss meta data on trades UpstoxDeveloperApi.UserApi | getProfile | GET /user/profile | Get profile UpstoxDeveloperApi.UserApi | getUserFundMargin | GET /user/get-funds-and-margin | Get User Fund And Margin UpstoxDeveloperApi.WebsocketApi | getMarketDataFeed | GET /feed/market-data-feed | Market Data Feed UpstoxDeveloperApi.WebsocketApi | getMarketDataFeedAuthorize | GET /feed/market-data-feed/authorize | Market Data Feed Authorize UpstoxDeveloperApi.WebsocketApi | getPortfolioStreamFeed | GET /feed/portfolio-stream-feed | Portfolio Stream Feed UpstoxDeveloperApi.WebsocketApi | getPortfolioStreamFeedAuthorize | GET /feed/portfolio-stream-feed/authorize | Portfolio Stream Feed Authorize
Documentation for Models
- UpstoxDeveloperApi.ApiGatewayErrorResponse
- UpstoxDeveloperApi.BrokerageData
- UpstoxDeveloperApi.BrokerageTaxes
- UpstoxDeveloperApi.BrokerageWrapperData
- UpstoxDeveloperApi.CancelOrderData
- UpstoxDeveloperApi.CancelOrderResponse
- UpstoxDeveloperApi.ConvertPositionData
- UpstoxDeveloperApi.ConvertPositionRequest
- UpstoxDeveloperApi.ConvertPositionResponse
- UpstoxDeveloperApi.Depth
- UpstoxDeveloperApi.DepthMap
- UpstoxDeveloperApi.DpPlan
- UpstoxDeveloperApi.GetBrokerageResponse
- UpstoxDeveloperApi.GetFullMarketQuoteResponse
- UpstoxDeveloperApi.GetHistoricalCandleResponse
- UpstoxDeveloperApi.GetHoldingsResponse
- UpstoxDeveloperApi.GetIntraDayCandleResponse
- UpstoxDeveloperApi.GetMarketQuoteLastTradedPriceResponse
- UpstoxDeveloperApi.GetMarketQuoteOHLCResponse
- UpstoxDeveloperApi.GetOrderBookResponse
- UpstoxDeveloperApi.GetOrderResponse
- UpstoxDeveloperApi.GetPositionResponse
- UpstoxDeveloperApi.GetProfileResponse
- UpstoxDeveloperApi.GetProfitAndLossChargesResponse
- UpstoxDeveloperApi.GetTradeResponse
- UpstoxDeveloperApi.GetTradeWiseProfitAndLossDataResponse
- UpstoxDeveloperApi.GetTradeWiseProfitAndLossMetaDataResponse
- UpstoxDeveloperApi.GetUserFundMarginResponse
- UpstoxDeveloperApi.HistoricalCandleData
- UpstoxDeveloperApi.HoldingsData
- UpstoxDeveloperApi.IntraDayCandleData
- UpstoxDeveloperApi.LogoutResponse
- UpstoxDeveloperApi.MarketQuoteOHLC
- UpstoxDeveloperApi.MarketQuoteSymbol
- UpstoxDeveloperApi.MarketQuoteSymbolLtp
- UpstoxDeveloperApi.ModifyOrderData
- UpstoxDeveloperApi.ModifyOrderRequest
- UpstoxDeveloperApi.ModifyOrderResponse
- UpstoxDeveloperApi.OAuthClientException
- UpstoxDeveloperApi.OAuthClientExceptionCause
- UpstoxDeveloperApi.OAuthClientExceptionCauseStackTrace
- UpstoxDeveloperApi.OAuthClientExceptionCauseSuppressed
- UpstoxDeveloperApi.Ohlc
- UpstoxDeveloperApi.OrderBookData
- UpstoxDeveloperApi.OrderData
- UpstoxDeveloperApi.OtherTaxes
- UpstoxDeveloperApi.PlaceOrderData
- UpstoxDeveloperApi.PlaceOrderRequest
- UpstoxDeveloperApi.PlaceOrderResponse
- UpstoxDeveloperApi.PositionData
- UpstoxDeveloperApi.Problem
- UpstoxDeveloperApi.ProfileData
- UpstoxDeveloperApi.ProfitAndLossChargesData
- UpstoxDeveloperApi.ProfitAndLossChargesTaxes
- UpstoxDeveloperApi.ProfitAndLossChargesWrapperData
- UpstoxDeveloperApi.ProfitAndLossMetaData
- UpstoxDeveloperApi.ProfitAndLossMetaDataWrapper
- UpstoxDeveloperApi.ProfitAndLossOtherChargesTaxes
- UpstoxDeveloperApi.TokenRequest
- UpstoxDeveloperApi.TokenResponse
- UpstoxDeveloperApi.TradeData
- UpstoxDeveloperApi.TradeWiseMetaData
- UpstoxDeveloperApi.TradeWiseProfitAndLossData
- UpstoxDeveloperApi.UserFundMarginData
- UpstoxDeveloperApi.WebsocketAuthRedirectResponse
- UpstoxDeveloperApi.WebsocketAuthRedirectResponseData
Documentation for Authorization
OAUTH2
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://api-v2.upstox.com/login/authorization/dialog
- Scopes:
- :