Websockets
You can access any endpoint via websockets if you have subscriped to the premium or enterprise package.
Websockets support bidirectional communication and reduce latency and are recommended for realtime data.
Getting Started
The format of the websocket request is the following:
json = {
"action": <action>,
"symbol": <symbol>,
}
and the data is the same as the body
parameter that you will send to the REST-API.
The work similar to the REST-API:
- First connect to
wss://ws.bavest.co/v0
and use the header{"x-api-key": "<API KEY>" }
- Send the
json
to the socket - Response is the same as REST-API response
CLI command:
wscat -c "wss://ws.bavest.co/v0" -H "x-api-key: <API KEY>"
Actions
Action | Description | Reference |
---|---|---|
ping | Ping the websocket to keep active. | None |
quote | The quote endpoint. The difference between /quote and /stock/quote is that /quote is realtime. | Quote |
stock/candle | The stock candle endpoint returnss the candles for a given symbol or ISIN. Candles are from EURONEXT. | Historical Stock Data |
stock/dividend | Get dividends data for common stocks going back 30 years. | Stock Dividends |
stock/fundamentals | The stock fundamentals endpoint. | Fundamentals |
stock/esg | The stock ESG endpoint returnss company ESG data. | ESG |
stock/financials | The stock financials endpoint returns the financials e.g. balance sheet, income sheet or cashflow statement. | Financials |
stock/metric | Get company price performance statistics such as 52-week high/low, returns and growth rations. | Metrics |
stock/news | The news endpoint returns the latest stock news. | News |
stock/peers | The stock widget peers endpoint. | Peers |
stock/profile | Get general information of a company. | Profile |
For more information read the REST API documentation.
Other Actions
The ping
command is used to keep the socket alive. The socket will close after 15min of inactivity. Therefore, it is required to send a periodically ping
. The Websocket return pong
to indicate that the socket is alive.
Updated 9 months ago