UNPKG

upstox-js-sdk

Version:

The official Node Js client for communicating with the Upstox API

212 lines (202 loc) 10.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WebsocketApi = void 0; var _ApiClient = require("../ApiClient"); var _ApiGatewayErrorResponse = require("../model/ApiGatewayErrorResponse"); var _WebsocketAuthRedirectResponse = require("../model/WebsocketAuthRedirectResponse"); /* * 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. * */ /** * Websocket service. * @module api/WebsocketApi * @version v2 */ class WebsocketApi { /** * Constructs a new WebsocketApi. * @alias module:api/WebsocketApi * @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.ApiClient.instance; } /** * Callback function to receive the result of the getMarketDataFeed operation. * @callback moduleapi/WebsocketApi~getMarketDataFeedCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Market Data Feed * This API redirects the client to the respective socket endpoint to receive Market updates. * @param {String} apiVersion API Version Header * @param {module:api/WebsocketApi~getMarketDataFeedCallback} callback The callback function, accepting three arguments: error, data, response */ getMarketDataFeed(apiVersion, callback) { let postBody = null; // verify the required parameter 'apiVersion' is set if (apiVersion === undefined || apiVersion === null) { throw new Error("Missing the required parameter 'apiVersion' when calling getMarketDataFeed"); } let pathParams = {}; let queryParams = {}; let headerParams = { 'Api-Version': apiVersion }; let formParams = {}; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['*/*']; let returnType = null; return this.apiClient.callApi('/v2/feed/market-data-feed', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Market Data Feed * This API redirects the client to the respective socket endpoint to receive Market updates. * @param {module:api/WebsocketApi~getMarketDataFeedCallback} callback The callback function, accepting three arguments: error, data, response */ getMarketDataFeedV3(callback) { let postBody = null; let pathParams = {}; let queryParams = {}; let headerParams = {}; let formParams = {}; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['*/*']; let returnType = null; return this.apiClient.callApi('/v3/feed/market-data-feed', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Callback function to receive the result of the getMarketDataFeedAuthorize operation. * @callback moduleapi/WebsocketApi~getMarketDataFeedAuthorizeCallback * @param {String} error Error message, if any. * @param {module:model/WebsocketAuthRedirectResponse{ data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Market Data Feed Authorize * This API provides the functionality to retrieve the socket endpoint URI for Market updates. * @param {String} apiVersion API Version Header * @param {module:api/WebsocketApi~getMarketDataFeedAuthorizeCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link <&vendorExtensions.x-jsdoc-type>} */ getMarketDataFeedAuthorize(apiVersion, callback) { let postBody = null; // verify the required parameter 'apiVersion' is set if (apiVersion === undefined || apiVersion === null) { throw new Error("Missing the required parameter 'apiVersion' when calling getMarketDataFeedAuthorize"); } let pathParams = {}; let queryParams = {}; let headerParams = { 'Api-Version': apiVersion }; let formParams = {}; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['*/*', 'application/json']; let returnType = _WebsocketAuthRedirectResponse.WebsocketAuthRedirectResponse; return this.apiClient.callApi('/v2/feed/market-data-feed/authorize', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Market Data Feed Authorize * This API provides the functionality to retrieve the socket endpoint URI for Market updates. * @param {module:api/WebsocketApi~getMarketDataFeedAuthorizeCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link <&vendorExtensions.x-jsdoc-type>} */ getMarketDataFeedAuthorizeV3(callback) { let postBody = null; let pathParams = {}; let queryParams = {}; let headerParams = {}; let formParams = {}; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['*/*', 'application/json']; let returnType = _WebsocketAuthRedirectResponse.WebsocketAuthRedirectResponse; return this.apiClient.callApi('/v3/feed/market-data-feed/authorize', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Callback function to receive the result of the getPortfolioStreamFeed operation. * @callback moduleapi/WebsocketApi~getPortfolioStreamFeedCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Portfolio Stream Feed * This API redirects the client to the respective socket endpoint to receive Portfolio updates. * @param {String} apiVersion API Version Header * @param {module:api/WebsocketApi~getPortfolioStreamFeedCallback} callback The callback function, accepting three arguments: error, data, response */ getPortfolioStreamFeed(apiVersion, callback) { let postBody = null; // verify the required parameter 'apiVersion' is set if (apiVersion === undefined || apiVersion === null) { throw new Error("Missing the required parameter 'apiVersion' when calling getPortfolioStreamFeed"); } let pathParams = {}; let queryParams = {}; let headerParams = { 'Api-Version': apiVersion }; let formParams = {}; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['*/*']; let returnType = null; return this.apiClient.callApi('/v2/feed/portfolio-stream-feed', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Callback function to receive the result of the getPortfolioStreamFeedAuthorize operation. * @callback moduleapi/WebsocketApi~getPortfolioStreamFeedAuthorizeCallback * @param {String} error Error message, if any. * @param {module:model/WebsocketAuthRedirectResponse{ data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Portfolio Stream Feed Authorize * This API provides the functionality to retrieve the socket endpoint URI for Portfolio updates. * @param {String} apiVersion API Version Header * @param {module:api/WebsocketApi~getPortfolioStreamFeedAuthorizeCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link <&vendorExtensions.x-jsdoc-type>} */ getPortfolioStreamFeedAuthorize(apiVersion, callback) { let postBody = null; // verify the required parameter 'apiVersion' is set if (apiVersion === undefined || apiVersion === null) { throw new Error("Missing the required parameter 'apiVersion' when calling getPortfolioStreamFeedAuthorize"); } let pathParams = {}; let queryParams = {}; let headerParams = { 'Api-Version': apiVersion }; let formParams = {}; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['*/*', 'application/json']; let returnType = _WebsocketAuthRedirectResponse.WebsocketAuthRedirectResponse; return this.apiClient.callApi('/v2/feed/portfolio-stream-feed/authorize', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } } exports.WebsocketApi = WebsocketApi;