{"id":38584363,"url":"https://github.com/upstox/upstox-nodejs","last_synced_at":"2026-01-17T08:18:00.796Z","repository":{"id":46174179,"uuid":"83460415","full_name":"upstox/upstox-nodejs","owner":"upstox","description":"Official NodeJS library for accessing Upstox APIs","archived":false,"fork":false,"pushed_at":"2025-11-24T14:10:35.000Z","size":2070,"stargazers_count":38,"open_issues_count":1,"forks_count":22,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-11-28T03:16:59.709Z","etag":null,"topics":["javascript","nodejs","nodejs-modules"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/upstox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-02-28T17:25:53.000Z","updated_at":"2025-11-24T14:10:35.000Z","dependencies_parsed_at":"2025-02-23T06:37:34.728Z","dependency_job_id":"74618920-771d-4e8a-a2dc-fb85def168c6","html_url":"https://github.com/upstox/upstox-nodejs","commit_stats":{"total_commits":134,"total_committers":9,"mean_commits":14.88888888888889,"dds":0.4402985074626866,"last_synced_commit":"79700847eda731a472a2e432481b69be879730f4"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/upstox/upstox-nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/upstox","download_url":"https://codeload.github.com/upstox/upstox-nodejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-nodejs/sbom","scorecard":{"id":911521,"data":{"date":"2025-08-11","repo":{"name":"github.com/upstox/upstox-nodejs","commit":"60f730c652af5d55c466205f70f946a3217de752"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":1,"reason":"2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/semgrep.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/semgrep.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/upstox/upstox-nodejs/semgrep.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/semgrep.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/upstox/upstox-nodejs/semgrep.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":4,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'master'","Info: 'force pushes' disabled on branch 'master'","Info: 'branch protection settings apply to administrators' is required to merge on branch 'master'","Warn: 'stale review dismissal' is disabled on branch 'master'","Warn: required approving review count is 1 on branch 'master'","Warn: codeowners review is required - but no codeowners file found in repo","Warn: 'last push approval' is disabled on branch 'master'","Warn: 'up-to-date branches' is disabled on branch 'master'","Info: status check found to merge onto on branch 'master'","Info: PRs are required in order to make changes on branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"30 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27","Warn: Project is vulnerable to: GHSA-4www-5p9h-95mh","Warn: Project is vulnerable to: GHSA-9gqv-wp59-fq42","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986","Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6","Warn: Project is vulnerable to: GHSA-4v9v-hfq4-rm2v","Warn: Project is vulnerable to: GHSA-9jgg-88mc-972h","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T19:23:24.774Z","repository_id":46174179,"created_at":"2025-08-24T19:23:24.774Z","updated_at":"2025-08-24T19:23:24.774Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28504359,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","nodejs-modules"],"created_at":"2026-01-17T08:18:00.703Z","updated_at":"2026-01-17T08:18:00.778Z","avatar_url":"https://github.com/upstox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Upstox Node Js SDK for API v2\n\n## Introduction\n\nThe official Node.js client for communicating with the \u003ca href=\"https://upstox.com/uplink/\"\u003eUpstox API\u003c/a\u003e.\n\nUpstox 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. \n\n- API version: v2\n- Build package: io.swagger.codegen.v3.generators.javascript.JavaScriptClientCodegen\n\nThis SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project.\n\n## Documentation.\n\n\u003ca href=\"https://upstox.com/developer/api-documentation\"\u003eUpstox API Documentation\u003c/a\u003e\n\n## Installation\n\n### For [Node.js](https://nodejs.org/)\n\n#### npm\n\n```shell\nnpm install upstox-js-sdk --save\n```\n\n## Examples\n\n[Sample Implementations](examples/) can be found within `/examples` folder.\n\n- [Websocket Market data](examples/websocket/market_data/)\n- [Websocket Order updates](examples/websocket/order_updates/)\n\n## Sandbox Mode\nWe recommend using the sandbox environment for testing purposes. To enable sandbox mode, set the `sandbox` flag to `true` in the client object.\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet sandboxClient = new UpstoxClient.ApiClient(true);\nsandboxClient.authentications[\"OAUTH2\"].accessToken = \"SANDBOX_ACCESS_TOKEN\";\n\n\nlet apiInstance = new UpstoxClient.OrderApiV3();\nlet body = new UpstoxClient.PlaceOrderV3Request(1,UpstoxClient.PlaceOrderV3Request.ProductEnum.D,\n    UpstoxClient.PlaceOrderV3Request.ValidityEnum.DAY, 0,\"NSE_EQ|INE528G01035\",UpstoxClient.PlaceOrderV3Request.OrderTypeEnum.MARKET,\n    UpstoxClient.PlaceOrderV3Request.TransactionTypeEnum.BUY,0,0,true);\nlet opt = {\"slice\": true}\napiInstance.placeOrder(body, opt, (error, data, response) =\u003e {\n  if (error) {\n    console.log(\"error-\u003e\" + JSON.stringify(error));\n  } else {\n    console.log('API called successfully. Returned data: ' + JSON.stringify(data));\n  }\n});\n```\nTo learn more about the sandbox environment and the available sandbox APIs, please visit the [Upstox API documentation - Sandbox](https://upstox.com/developer/api-documentation/sandbox).\n\n## Algo Name Support\n\nThe SDK supports passing an algorithm ID for order tracking and management. When provided, the SDK will pass the algo ID as `X-Algo-Name` header.\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \"ACCESS_TOKEN\";\n\nlet apiInstance = new UpstoxClient.OrderApiV3();\nlet body = new UpstoxClient.PlaceOrderV3Request(1,UpstoxClient.PlaceOrderV3Request.ProductEnum.D,\n    UpstoxClient.PlaceOrderV3Request.ValidityEnum.DAY, 0,\"NSE_EQ|INE528G01035\",UpstoxClient.PlaceOrderV3Request.OrderTypeEnum.MARKET,\n    UpstoxClient.PlaceOrderV3Request.TransactionTypeEnum.BUY,0,0,true);\nlet opt = {\"slice\": true}\n\napiInstance.placeOrder(body, opt, (error, data, response) =\u003e {\n  if (error) {\n    console.log(\"error-\u003e\" + JSON.stringify(error));\n  } else {\n    console.log('API called successfully. Returned data: ' + JSON.stringify(data));\n  }\n}, \"your-algo-name\");\n```\n\nOther order methods (modify, cancel, etc.) follow the same pattern by accepting an optional algo name as the last parameter.\n\n\n## Documentation for API Endpoints\n\n- Place, Modify, and Cancel Order APIs are relative to `https://api-hft.upstox.com`\n- All other APIs are relative to `https://api.upstox.com`\n\nAPI Name | HTTP Request | Class | Documentation | Sample Codes\n------------ | ------------- | ------------- | ------------- | -------------\n**Expired Instruments** | | | |\nGet Expiries | **GET** /v2/expired-instruments/expiries| *ExpiredInstrumentApi* | [API Reference](https://upstox.com/developer/api-documentation/get-expiries) | [Sample Code](https://upstox.com/developer/api-documentation/get-expiries#sample-code-nodejs_sdk)\nGet Expired Option Contracts | **GET**  /v2/expired-instruments/option/contract| *ExpiredInstrumentApi* | [API Reference](https://upstox.com/developer/api-documentation/get-expired-option-contracts) | [Sample Code](https://upstox.com/developer/api-documentation/get-expired-option-contracts#sample-code-nodejs_sdk)\nGet Expired Future Contracts | **GET** /v2/expired-instruments/future/contract| *ExpiredInstrumentApi* | [API Reference](https://upstox.com/developer/api-documentation/get-expired-future-contracts) | [Sample Code](https://upstox.com/developer/api-documentation/get-expired-future-contracts#sample-code-nodejs_sdk)\nGet Expired Historical Candle Data | **GET** /v2/expired-instruments/historical-candle/{expired_instrument_key}/{interval}/{to_date}/{from_date}| *ExpiredInstrumentApi* | [API Reference](https://upstox.com/developer/api-documentation/get-expired-historical-candle-data) | [Sample Code](https://upstox.com/developer/api-documentation/get-expired-historical-candle-data#sample-code-nodejs_sdk)\n**Login** | | | |\nGet Token | **POST** /v2/login/authorization/token | *LoginApi* | [API Reference](https://upstox.com/developer/api-documentation/get-token) | [Sample Code](https://upstox.com/developer/api-documentation/get-token#sample-code-nodejs_sdk)\nAccess Token Request | **POST** /v3/login/auth/token/request/{client_id} | *LoginApi* | [API Reference](https://upstox.com/developer/api-documentation/access-token-request) | [Sample Code](https://upstox.com/developer/api-documentation/access-token-request#sample-code-nodejs_sdk)\nLogout | **DELETE** /v2/logout | *LoginApi* | [API Reference](https://upstox.com/developer/api-documentation/logout) | [Sample Code](https://upstox.com/developer/api-documentation/logout#sample-code-nodejs_sdk)\n**User** | | | |\nGet Profile | **GET** /v2/user/profile | *UserApi* | [API Reference](https://upstox.com/developer/api-documentation/get-profile) | [Sample Code](https://upstox.com/developer/api-documentation/get-profile#sample-code-nodejs_sdk)\nGet User Fund Margin | **GET** /v2/user/get-funds-and-margin | *UserApi* | [API Reference](https://upstox.com/developer/api-documentation/get-user-fund-margin) | [Sample Code](https://upstox.com/developer/api-documentation/get-user-fund-margin#sample-code-nodejs_sdk)\n**Charges** | | | |\nGet Brokerage | **GET** /v2/charges/brokerage | *ChargeApi* | [API Reference](https://upstox.com/developer/api-documentation/get-brokerage) | [Sample Code](https://upstox.com/developer/api-documentation/get-brokerage#sample-code-nodejs_sdk)\n**Margins** | | | |\nMargin | **POST** /v2/charges/margin | *ChargeApi* | [API Reference](https://upstox.com/developer/api-documentation/margin) | [Sample Code](https://upstox.com/developer/api-documentation/margin#sample-code-nodejs_sdk)\n**Orders** | | | |\nPlace Order V3 | **POST** /v3/order/place | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/v3/place-order) | [Sample Code](https://upstox.com/developer/api-documentation/v3/place-order#sample-code-nodejs_sdk)\nPlace Multi Order | **POST** /v2/order/multi/place | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/place-multi-order) | [Sample Code](https://upstox.com/developer/api-documentation/place-multi-order#sample-code-nodejs_sdk)\nModify Order V3 | **PUT** /v3/order/modify | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/v3/modify-order) | [Sample Code](https://upstox.com/developer/api-documentation/v3/modify-order#sample-code-nodejs_sdk)\nCancel Order V3 | **DELETE** /v3/order/cancel | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/v3/cancel-order) | [Sample Code](https://upstox.com/developer/api-documentation/v3/cancel-order#sample-code-nodejs_sdk)\nCancel Multi Order | **DELETE** /v2/order/multi/cancel | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/cancel-multi-order) | [Sample Code](https://upstox.com/developer/api-documentation/cancel-multi-order#sample-code-nodejs_sdk)\nExit All Position | **POST** /v2/order/positions/exit | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/exit-all-positions) | [Sample Code](https://upstox.com/developer/api-documentation/exit-all-positions#sample-code-nodejs_sdk)\nGet Order Details | **GET** /v2/order/details | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/get-order-details) | [Sample Code](https://upstox.com/developer/api-documentation/get-order-details#sample-code-nodejs_sdk)\nGet Order History | **GET** /v2/order/history | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/get-order-history) | [Sample Code](https://upstox.com/developer/api-documentation/get-order-history#sample-code-nodejs_sdk)\nGet Trades By Order | **GET** /v2/order/trades | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/get-trades-by-order) | [Sample Code](https://upstox.com/developer/api-documentation/get-trades-by-order#sample-code-nodejs_sdk)\nGet Trade History | **GET** /v2/order/trades/get-trades-for-day | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/get-trade-history) | [Sample Code](https://upstox.com/developer/api-documentation/get-trade-history#sample-code-nodejs_sdk)\n**GTT Order** | | | |\nPlace GTT Order | **POST** /v3/order/gtt/place | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/place-gtt-order) | [Sample Code](https://upstox.com/developer/api-documentation/place-gtt-order#sample-code-nodejs_sdk)\nModify GTT Order | **PUT** /v3/order/gtt/modify | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/modify-gtt-order) | [Sample Code](https://upstox.com/developer/api-documentation/modify-gtt-order#sample-code-nodejs_sdk)\nCancel GTT Order | **DELETE** /v3/order/gtt/cancel | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/cancel-gtt-order) | [Sample Code](https://upstox.com/developer/api-documentation/cancel-gtt-order#sample-code-nodejs_sdk)\nGet GTT Order Details | **GET** /v3/order/gtt | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/get-gtt-order-details) | [Sample Code](https://upstox.com/developer/api-documentation/get-gtt-order-details#sample-code-nodejs_sdk)\n**Portfolio** | | | |\nGet Positions | **GET** /v2/portfolio/short-term-positions | *PortfolioApi* | [API Reference](https://upstox.com/developer/api-documentation/get-positions) | [Sample Code](https://upstox.com/developer/api-documentation/get-positions#sample-code-nodejs_sdk)\nGet MTF Positions | **GET** /v3/portfolio/mtf | *PortfolioApi* | [API Reference](https://upstox.com/developer/api-documentation/get-mtf-positions) | [Sample Code](https://upstox.com/developer/api-documentation/get-mtf-positions#sample-code-nodejs_sdk)\nConvert Positions | **PUT** /v2/portfolio/convert-position | *PortfolioApi* | [API Reference](https://upstox.com/developer/api-documentation/convert-positions) | [Sample Code](https://upstox.com/developer/api-documentation/convert-positions#sample-code-nodejs_sdk)\nGet Holdings | **GET** /v2/portfolio/long-term-holdings | *PortfolioApi* | [API Reference](https://upstox.com/developer/api-documentation/get-holdings) | [Sample Code](https://upstox.com/developer/api-documentation/get-holdings#sample-code-nodejs_sdk)\n**Trade Profit And Loss** | | | |\nGet Report Meta Data | **GET** /v2/trade/profit-loss/metadata | *TradeProfitAndLossApi* | [API Reference](https://upstox.com/developer/api-documentation/get-report-meta-data) | [Sample Code](https://upstox.com/developer/api-documentation/get-report-meta-data#sample-code-nodejs_sdk)\nGet Profit And Loss Report | **GET** /v2/trade/profit-loss/data | *TradeProfitAndLossApi* | [API Reference](https://upstox.com/developer/api-documentation/get-profit-and-loss-report) | [Sample Code](https://upstox.com/developer/api-documentation/get-profit-and-loss-report#sample-code-nodejs_sdk)\nGet Trade Charges | **GET** /v2/trade/profit-loss/charges | *TradeProfitAndLossApi* | [API Reference](https://upstox.com/developer/api-documentation/get-trade-charges) | [Sample Code](https://upstox.com/developer/api-documentation/get-trade-charges#sample-code-nodejs_sdk)\n**Historical Data** | | | |\nGet Historical Candle Data V3 | **GET** /v3/historical-candle | *HistoryV3Api* | [API Reference](https://upstox.com/developer/api-documentation/v3/get-historical-candle-data) | [Sample Code](https://upstox.com/developer/api-documentation/v3/get-historical-candle-data#sample-code-nodejs_sdk)\nGet Intra Day Candle Data V3 | **GET** /v3/intra-day-candle | *HistoryV3Api* | [API Reference](https://upstox.com/developer/api-documentation/v3/get-intra-day-candle-data) | [Sample Code](https://upstox.com/developer/api-documentation/v3/get-intra-day-candle-data#sample-code-nodejs_sdk)\n**Market Quote** | | | |\nGet Full Market Quote | **GET** /v2/market-quote/quotes | *MarketQuoteApi* | [API Reference](https://upstox.com/developer/api-documentation/get-full-market-quote) | [Sample Code](https://upstox.com/developer/api-documentation/get-full-market-quote#sample-code-nodejs_sdk)\nGet Market Quote OHLC | **GET** /v2/market-quote/ohlc | *MarketQuoteApi* | [API Reference](https://upstox.com/developer/api-documentation/get-market-quote-ohlc) | [Sample Code](https://upstox.com/developer/api-documentation/get-market-quote-ohlc#sample-code-nodejs_sdk)\nLTP V3 | **GET** /v3/market-quote/ltp | *MarketQuoteV3Api* | [API Reference](https://upstox.com/developer/api-documentation/ltp-v3) | [Sample Code](https://upstox.com/developer/api-documentation/ltp-v3#sample-code-nodejs_sdk)\nOption Greek | **GET** /v3/market-quote/greeks | *MarketQuoteV3Api* | [API Reference](https://upstox.com/developer/api-documentation/option-greek) | [Sample Code](https://upstox.com/developer/api-documentation/option-greek#sample-code-nodejs_sdk)\n**Market Information** | | | |\nGet Market Holidays | **GET** /v2/market/holidays | *MarketHolidaysAndTimingsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-market-holidays) | [Sample Code](https://upstox.com/developer/api-documentation/get-market-holidays#sample-code-nodejs_sdk)\nGet Market Timings | **GET** /v2/market/timings | *MarketHolidaysAndTimingsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-market-timings) | [Sample Code](https://upstox.com/developer/api-documentation/get-market-timings#sample-code-nodejs_sdk)\nGet Market Status | **GET** /v2/market/status | *MarketHolidaysAndTimingsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-market-status) | [Sample Code](https://upstox.com/developer/api-documentation/get-market-status#sample-code-nodejs_sdk)\n**Option Chain** | | | |\nGet Option Contracts | **GET** /v2/option/contract | *OptionsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-option-contracts) | [Sample Code](https://upstox.com/developer/api-documentation/get-option-contracts#sample-code-nodejs_sdk)\nGet PC Option Chain | **GET** /v2/option/chain | *OptionsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-pc-option-chain) | [Sample Code](https://upstox.com/developer/api-documentation/get-pc-option-chain#sample-code-nodejs_sdk)\n\n## Documentation for Feeder Functions\n\nConnecting to the WebSocket for market and portfolio updates is streamlined through two primary Feeder functions:\n\n1. **MarketDataStreamer**: Offers real-time market updates, providing a seamless way to receive instantaneous information on various market instruments.\n2. **PortfolioDataStreamer**: Delivers updates related to the user's orders, enhancing the ability to track order status and portfolio changes effectively.\n\nBoth functions are designed to simplify the process of subscribing to essential data streams, ensuring users have quick and easy access to the information they need.\n\n### Detailed Explanation of Feeder Functions\n\n### MarketDataStreamer\n\nThe `MarketDataStreamerV3` function is designed for effortless connection to the market WebSocket, enabling users to receive instantaneous updates on various instruments. The following example demonstrates how to quickly set up and start receiving market updates for selected instrument keys:\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \u003cACCESS_TOKEN\u003e;\n\nconst streamer = new UpstoxClient.MarketDataStreamerV3([\"MCX_FO|426268\", \"MCX_FO|427608\"], \"full\");\nstreamer.connect();\n\nstreamer.on(\"message\", (data) =\u003e {\n  const feed = data.toString(\"utf-8\");\n  console.log(feed);\n});\n```\n\nIn this example, you first authenticate using an access token, then instantiate MarketDataStreamerV3 with specific instrument keys and a subscription mode. Upon connecting, the streamer listens for market updates, which are logged to the console as they arrive.\n\nFeel free to adjust the access token placeholder and any other specifics to better fit your actual implementation or usage scenario.\n\n### Exploring the MarketDataStreamerV3 Functionality\n\n#### Modes\n- **ltpc**: ltpc provides information solely about the most recent trade, encompassing details such as the last trade price, time of the last trade, quantity traded, and the closing price from the previous day.\n- **full**: The full option offers comprehensive information, including the latest trade prices, D5 depth, 1-minute, 30-minute, and daily candlestick data, along with some additional details.\n- **full_d30**: full_d30 includes Full mode data plus 30 market level quotes.      \n- **option_greeks**: Contains only option greeks.\n\n#### Functions\n1. **constructor MarketDataStreamerV3(instrumentKeys, mode)**: Initializes the streamer with optional instrument keys and mode (`full`, `ltpc`, `full_d30` or `option_greeks`).\n2. **connect()**: Establishes the WebSocket connection.\n3. **subscribe(instrumentKeys, mode)**: Subscribes to updates for given instrument keys in the specified mode. Both parameters are mandatory.\n4. **unsubscribe(instrumentKeys)**: Stops updates for the specified instrument keys.\n5. **changeMode(instrumentKeys, mode)**: Switches the mode for already subscribed instrument keys.\n6. **disconnect()**: Ends the active WebSocket connection.\n7. **autoReconnect(enable, interval, retryCount)**: Customizes auto-reconnect functionality. Parameters include a flag to enable/disable it, the interval(in seconds) between attempts, and the maximum number of retries.\n\n#### Events\n- **open**: Emitted upon successful connection establishment.\n- **close**: Indicates the WebSocket connection has been closed.\n- **message**: Delivers market updates.\n- **error**: Signals an error has occurred.\n- **reconnecting**: Announced when a reconnect attempt is initiated.\n- **autoReconnectStopped**: Informs when auto-reconnect efforts have ceased after exhausting the retry count.\n\nThe following documentation includes examples to illustrate the usage of these functions and events, providing a practical understanding of how to interact with the MarketDataStreamerV3 effectively.\n\n\u003cbr/\u003e\n\n1. Subscribing to Market Data on Connection Open with MarketDataStreameV3\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \u003cACCESS_TOKEN\u003e;\n\nconst streamer = new UpstoxClient.MarketDataStreamerV3();\nstreamer.connect();\n\n// Subscribe to instrument keys upon the 'open' event\nstreamer.on(\"open\", () =\u003e {\n  streamer.subscribe([\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"], \"full\");\n});\n\n// Handle incoming market data messages\nstreamer.on(\"message\", (data) =\u003e {\n  const feed = data.toString(\"utf-8\");\n  console.log(feed);\n});\n```\n\n\u003cbr/\u003e\n\n2. Subscribing to Instruments with Delays\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \u003cACCESS_TOKEN\u003e;\n\nconst streamer = new UpstoxClient.MarketDataStreamerV3();\nstreamer.connect();\n\n// Subscribe to the first set of instrument keys immediately upon connection\nstreamer.on(\"open\", () =\u003e {\n  streamer.subscribe([\"NSE_EQ|INE020B01018\"], \"full\");\n  \n  // Subscribe to another set of instrument keys after a delay\n  setTimeout(() =\u003e {\n    streamer.subscribe([\"NSE_EQ|INE467B01029\"], \"full\");\n  }, 5000); // 5-second delay before subscribing to the second set\n});\n\n// Handle incoming market data messages\nstreamer.on(\"message\", (data) =\u003e {\n  const feed = data.toString(\"utf-8\");\n  console.log(feed);\n});\n```\n\n\u003cbr/\u003e\n\n3. Subscribing and Unsubscribing to Instruments\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \u003cACCESS_TOKEN\u003e;\n\nconst streamer = new UpstoxClient.MarketDataStreamerV3();\nstreamer.connect();\n\n// Subscribe to instrument keys immediately upon connection\nstreamer.on(\"open\", () =\u003e {\n  console.log(\"Connected. Subscribing to instrument keys.\");\n  streamer.subscribe([\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"], \"full\");\n  \n  // Unsubscribe after a delay\n  setTimeout(() =\u003e {\n    console.log(\"Unsubscribing from instrument keys.\");\n    streamer.unsubscribe([\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"]);\n  }, 5000); // Adjust delay as needed\n});\n\nstreamer.on(\"message\", (data) =\u003e {\n  const feed = data.toString(\"utf-8\");\n  console.log(\"Market Update:\", feed);\n});\n```\n\n\u003cbr/\u003e\n\n4. Subscribe, Change Mode and Unsubscribe\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \u003cACCESS_TOKEN\u003e;\n\nconst streamer = new UpstoxClient.MarketDataStreamerV3();\nstreamer.connect();\n\n// Initially subscribe to instrument keys in 'full' mode\nstreamer.on(\"open\", async () =\u003e {\n  console.log(\"Connected. Subscribing in full mode...\");\n  streamer.subscribe([\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"], \"full\");\n\n  // Change mode to 'ltpc' after a short delay\n  setTimeout(() =\u003e {\n    console.log(\"Changing subscription mode to ltpc...\");\n    streamer.changeMode([\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"], \"ltpc\");\n  }, 5000); // 5-second delay\n\n  // Unsubscribe after another delay\n  setTimeout(() =\u003e {\n    console.log(\"Unsubscribing...\");\n    streamer.unsubscribe([\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"]);\n  }, 10000); // 10 seconds after subscription\n});\n\n// Setup event listeners to log messages, errors, and closure\nstreamer.on(\"message\", (data) =\u003e {\n  const feed = data.toString(\"utf-8\");\n  console.log(\"Market Update:\", feed);\n});\nstreamer.on(\"error\", (error) =\u003e console.error(\"Error:\", error));\nstreamer.on(\"close\", () =\u003e console.log(\"Connection closed.\"));\n```\n\n\u003cbr/\u003e\n\n5. Disable Auto-Reconnect\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \u003cACCESS_TOKEN\u003e;\n\nconst streamer = new UpstoxClient.MarketDataStreamerV3();\nstreamer.connect();\n\n// Disable auto-reconnect feature\nstreamer.autoReconnect(false);\n\nstreamer.on(\"autoReconnectStopped\", (data) =\u003e {\n  console.log(data);\n});\n```\n\n\u003cbr/\u003e\n\n6. Modify Auto-Reconnect parameters\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \u003cACCESS_TOKEN\u003e;\n\nconst streamer = new UpstoxClient.MarketDataStreamerV3();\nstreamer.connect();\n\n// Modify auto-reconnect parameters: enable it, set interval to 10 seconds, and retry count to 3\nstreamer.autoReconnect(true, 10, 3);\n```\n\n\u003cbr/\u003e\n\n### PortfolioDataStreamer\n\nConnecting to the Portfolio WebSocket for real-time order updates is straightforward with the PortfolioDataStreamer function. Below is a concise guide to get you started on receiving updates:\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \"\u003cACCESS_TOKEN\u003e\";\n\nconst streamer = new UpstoxClient.PortfolioDataStreamer();\nstreamer.connect();\n\nstreamer.on(\"message\", (data) =\u003e {\n  const feed = data.toString(\"utf-8\");\n  console.log(feed);\n});\n\n```\n\nThis example demonstrates initializing the PortfolioDataStreamer, connecting it to the WebSocket, and setting up an event listener to receive and print order updates. Replace \u003cACCESS_TOKEN\u003e with your valid access token to authenticate the session.\n\n### Exploring the PortfolioDataStreamer Functionality\n\n#### Functions\n1. **constructor PortfolioDataStreamer(orderUpdate = true, positionUpdate = false, holdingUpdate = false, gttUpdate = false)**: Initializes the streamer with options to receive different types of updates.\n2. **connect()**: Establishes the WebSocket connection.\n3. **disconnect()**: Ends the active WebSocket connection.\n4. **autoReconnect(enable, interval, retryCount)**: Customizes auto-reconnect functionality. Parameters include a flag to enable/disable it, the interval(in seconds) between attempts, and the maximum number of retries.\n\n#### Update Types\n- **orderUpdate**: Receive regular order updates (enabled by default)\n- **positionUpdate**: Receive position updates (disabled by default)\n- **holdingUpdate**: Receive holding updates (disabled by default)\n- **gttUpdate**: Receive GTT order updates (disabled by default)\n\n#### Events\n- **open**: Emitted upon successful connection establishment.\n- **close**: Indicates the WebSocket connection has been closed.\n- **message**: Delivers portfolio updates.\n- **error**: Signals an error has occurred.\n- **reconnecting**: Announced when a reconnect attempt is initiated.\n- **autoReconnectStopped**: Informs when auto-reconnect efforts have ceased after exhausting the retry count.\n\n#### Example with all update types enabled:\n\n```javascript\nlet UpstoxClient = require(\"upstox-js-sdk\");\nlet defaultClient = UpstoxClient.ApiClient.instance;\nvar OAUTH2 = defaultClient.authentications[\"OAUTH2\"];\nOAUTH2.accessToken = \"\u003cACCESS_TOKEN\u003e\";\n\n// Enable all update types: orders, positions, holdings, and GTT orders\nconst streamer = new UpstoxClient.PortfolioDataStreamer(true, true, true, true);\nstreamer.connect();\n\nstreamer.on(\"message\", (data) =\u003e {\n  const feed = data.toString(\"utf-8\");\n  console.log(feed);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupstox%2Fupstox-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fupstox%2Fupstox-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupstox%2Fupstox-nodejs/lists"}