UNPKG

upstox-js-sdk

Version:

The official Node Js client for communicating with the Upstox API

73 lines (61 loc) 1.79 kB
## Get news for instrument keys ```javascript let UpstoxClient = require('upstox-js-sdk'); let defaultClient = UpstoxClient.ApiClient.instance; var OAUTH2 = defaultClient.authentications['OAUTH2']; OAUTH2.accessToken = "{your_access_token}"; let apiInstance = new UpstoxClient.NewsApi(); let category = "instrument_keys"; let opts = { instrumentKeys: "NSE_EQ|INE669E01016", pageNumber: 1, pageSize: 10 }; apiInstance.getNews(category, opts, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + JSON.stringify(data)); } }); ``` ## Get news for current positions ```javascript let UpstoxClient = require('upstox-js-sdk'); let defaultClient = UpstoxClient.ApiClient.instance; var OAUTH2 = defaultClient.authentications['OAUTH2']; OAUTH2.accessToken = "{your_access_token}"; let apiInstance = new UpstoxClient.NewsApi(); let category = "positions"; let opts = { pageNumber: 1, pageSize: 10 }; apiInstance.getNews(category, opts, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + JSON.stringify(data)); } }); ``` ## Get news for current holdings ```javascript let UpstoxClient = require('upstox-js-sdk'); let defaultClient = UpstoxClient.ApiClient.instance; var OAUTH2 = defaultClient.authentications['OAUTH2']; OAUTH2.accessToken = "{your_access_token}"; let apiInstance = new UpstoxClient.NewsApi(); let category = "holdings"; let opts = { pageNumber: 1, pageSize: 10 }; apiInstance.getNews(category, opts, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + JSON.stringify(data)); } }); ```