angularwebsocketyahoo-api

Yahoo finance websocket & Angular


When accessing the Yahoo finance website (e.g. https://finance.yahoo.com/quote/AAPL/), the page connects to a WebSocket. The WebSocket URL is wss://streamer.finance.yahoo.com/

I'm trying to connect to that WebSocket and fetch some data for a small project. I'm using Angular, and have successfully connected to it using the following code:

import { webSocket } from 'rxjs/webSocket';

...

subject = webSocket('wss://streamer.finance.yahoo.com');

subscribeToWebsocket() {
  this.subject.subscribe((res) => {
    console.log('Response from websocket: ' + res);
  });

  this.subject.next({ subscribe: ['AAPL'] });
}

And this was working fine. But all of sudden, the WebSocket died on me, and won't send me any responses back.

Am I doing something wrong? Can Yahoo have blacklisted me or something? I find it odd that it stopped working.

The only unusual thing I notice is that the WS does not have that cog icon next to it, but I'm not sure what that means.

enter image description here


Solution

  • A little update for anyone who's trying to use this WS as well. THE WS is fine, it won't blacklist you or anything, it's just that after the stock market closes, you won't be getting any data - duh

    I'd recommend using cryptocurrency, since it never sleeps.