UNPKG

upstox-js-sdk

Version:

The official Node Js client for communicating with the Upstox API

202 lines (177 loc) 9.14 kB
/* * Upstox Developer API * Build your App on the Upstox platform ![Banner](https://api.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</a>.</br> 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. * * OpenAPI spec version: v2 * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * * Swagger Codegen version: 3.0.46 * * Do not edit the class manually. * */ import {ApiClient} from "../ApiClient"; import {ApiGatewayErrorResponse} from '../model/ApiGatewayErrorResponse'; import {GetFullMarketQuoteResponse} from '../model/GetFullMarketQuoteResponse'; import {GetMarketQuoteLastTradedPriceResponse} from '../model/GetMarketQuoteLastTradedPriceResponse'; import {GetMarketQuoteOHLCResponse} from '../model/GetMarketQuoteOHLCResponse'; /** * MarketQuote service. * @module api/MarketQuoteApi * @version v2 */ export class MarketQuoteApi { /** * Constructs a new MarketQuoteApi. * @alias module:api/MarketQuoteApi * @class * @param {module:ApiClient} [apiClient] Optional API client implementation to use, * default to {@link module:ApiClient#instanc e} if unspecified. */ constructor(apiClient) { this.apiClient = apiClient || ApiClient.instance; } /** * Callback function to receive the result of the getFullMarketQuote operation. * @callback moduleapi/MarketQuoteApi~getFullMarketQuoteCallback * @param {String} error Error message, if any. * @param {module:model/GetFullMarketQuoteResponse{ data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Market quotes and instruments - Full market quotes * This API provides the functionality to retrieve the full market quotes for one or more instruments.This API returns the complete market data snapshot of up to 500 instruments in one go. * @param {String} symbol Comma separated list of symbols * @param {String} apiVersion API Version Header * @param {module:api/MarketQuoteApi~getFullMarketQuoteCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link <&vendorExtensions.x-jsdoc-type>} */ getFullMarketQuote(symbol, apiVersion, callback) { let postBody = null; // verify the required parameter 'symbol' is set if (symbol === undefined || symbol === null) { throw new Error("Missing the required parameter 'symbol' when calling getFullMarketQuote"); } // verify the required parameter 'apiVersion' is set if (apiVersion === undefined || apiVersion === null) { throw new Error("Missing the required parameter 'apiVersion' when calling getFullMarketQuote"); } let pathParams = { }; let queryParams = { 'symbol': symbol }; let headerParams = { 'Api-Version': apiVersion }; let formParams = { }; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['application/json', '*/*']; let returnType = GetFullMarketQuoteResponse; return this.apiClient.callApi( '/v2/market-quote/quotes', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } /** * Callback function to receive the result of the getMarketQuoteOHLC operation. * @callback moduleapi/MarketQuoteApi~getMarketQuoteOHLCCallback * @param {String} error Error message, if any. * @param {module:model/GetMarketQuoteOHLCResponse{ data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Market quotes and instruments - OHLC quotes * This API provides the functionality to retrieve the OHLC quotes for one or more instruments.This API returns the OHLC snapshots of up to 1000 instruments in one go. * @param {String} symbol Comma separated list of symbols * @param {String} interval Interval to get ohlc data * @param {String} apiVersion API Version Header * @param {module:api/MarketQuoteApi~getMarketQuoteOHLCCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link <&vendorExtensions.x-jsdoc-type>} */ getMarketQuoteOHLC(symbol, interval, apiVersion, callback) { let postBody = null; // verify the required parameter 'symbol' is set if (symbol === undefined || symbol === null) { throw new Error("Missing the required parameter 'symbol' when calling getMarketQuoteOHLC"); } // verify the required parameter 'interval' is set if (interval === undefined || interval === null) { throw new Error("Missing the required parameter 'interval' when calling getMarketQuoteOHLC"); } // verify the required parameter 'apiVersion' is set if (apiVersion === undefined || apiVersion === null) { throw new Error("Missing the required parameter 'apiVersion' when calling getMarketQuoteOHLC"); } let pathParams = { }; let queryParams = { 'symbol': symbol,'interval': interval }; let headerParams = { 'Api-Version': apiVersion }; let formParams = { }; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['application/json', '*/*']; let returnType = GetMarketQuoteOHLCResponse; return this.apiClient.callApi( '/v2/market-quote/ohlc', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } /** * Callback function to receive the result of the ltp operation. * @callback moduleapi/MarketQuoteApi~ltpCallback * @param {String} error Error message, if any. * @param {module:model/GetMarketQuoteLastTradedPriceResponse{ data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Market quotes and instruments - LTP quotes. * This API provides the functionality to retrieve the LTP quotes for one or more instruments.This API returns the LTPs of up to 1000 instruments in one go. * @param {String} symbol Comma separated list of symbols * @param {String} apiVersion API Version Header * @param {module:api/MarketQuoteApi~ltpCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link <&vendorExtensions.x-jsdoc-type>} */ ltp(symbol, apiVersion, callback) { let postBody = null; // verify the required parameter 'symbol' is set if (symbol === undefined || symbol === null) { throw new Error("Missing the required parameter 'symbol' when calling ltp"); } // verify the required parameter 'apiVersion' is set if (apiVersion === undefined || apiVersion === null) { throw new Error("Missing the required parameter 'apiVersion' when calling ltp"); } let pathParams = { }; let queryParams = { 'symbol': symbol }; let headerParams = { 'Api-Version': apiVersion }; let formParams = { }; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['application/json', '*/*']; let returnType = GetMarketQuoteLastTradedPriceResponse; return this.apiClient.callApi( '/v2/market-quote/ltp', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } }