Websocket integration in Angular

Websocket :

curl -X 'GET' 
 -H 'accept: */*' 
 -H 'Api-Version: 2.0' 
 -H 'Authorization: Bearer access_token'

this APIs (websocket APIs) are not working as other api(s) mentioned in the documentation. getting error like


Welcome to the community!

Please note that https://api-v2.upstox.com/feed/market-data-feed should be accessed using a websocket client rather than a standard API call. However, you can use https://api-v2.upstox.com/feed/market-data-feed/authorize as a regular API endpoint to retrieve the full websocket URL. Once you have it, you can initiate a connection using a websocket client that suits your needs.

For a reference implementation using the Node.js SDK, please visit: https://github.com/upstox/upstox-nodejs/tree/master/examples/websocket/market_data.

Do reach out if you need further assistance or if this resolves your issue.

Thanks Shan,
I able to get full websocket url and connect web socket with status code :101
but when subscribe socket and listening msgs getting empty object

async ngOnInit(): Promise<void> {

    //NOTE:: Web Socket 
    let con_url:any= await this.upstoxSvr.get_upstock_ws_connection_url_portfolio().toPromise();
    this.upstoxsocket.socket$.subscribe((message) => {
      console.log('Received WebSocket message:', message);
    // END OF Eeb Socket 

can any one provide sample code which used with Angular or JavaScript plz

Following should help you get started with Portfolio Updates in Node.js

Let us know if this helped you.


This Node.js code i have reffered in API documentation. While I have attempted to translate the Node.js code, I have been able to establish a WebSocket connection but subscribing to real-time data feeds is not working.

Therefore, I kindly request your team’s assistance in providing a code sample specifically tailored for Angular, to receive WebSocket data feeds.


I understand your challenges with subscribing to real-time data feeds using the provided example.

Currently, we do not have a WebSocket example tailored specifically for Angular. However, the fundamental concepts and logic in the Node.js example can be adapted for use in an Angular environment. If you’re familiar with Angular services, you can integrate the WebSocket logic into a service to manage your real-time data needs.

While we aim to provide more extensive code samples in future documentation releases, we recommend using the Node.js example as a conceptual guide. Translating its core logic to fit Angular’s structure and patterns will be essential.

Should you have more questions or require further clarification, please don’t hesitate to reach out. Your feedback is valuable to us, and we’re here to assist.

Warm regards!!