Documentation for Volatility WebSockets API
npm install @volatility/volatility-wsThe Volatility WebSocket API follows similar interface patterns as popular platforms such as Kraken, Coinbase and deribit. This early version of the API only provides realtime data for MFIV 14 day ETH. Additional time periods, assets, methodologies, and historical data coming soon.
wss://ws.prd.volatility.com | For production and consumer facing use. |#collabland-join channel.#labs-volatility-api. Go to this channel and request an API key.If you clone this repository, you can run our example script in node by doing the following:
1. In your terminal run:
```
npm install
2. Add your API key as an environment variable. In your terminal run:
``
export VOLATILITY_API_KEY=
- Replace with your API key our team provided you.
3. In your terminal run:
``
ts-node src/example.ts
You can see the example script source code here.
Before you can use this package, you'll need to install it.
Install the package:
``
npm i @volatility/volatility-ws
After it's installed, import the realtimeVolatility method for use.
Example:
`
import { realtimeVolatility } from "volatility-api"
const messages = realtimeVolatility({
methodology: "MFIV"
timePeriod: "14D",
asset: "ETH",
apiKey: "
})
// process messages via async iteration:
for await (const message of messages) {
console.log(message);
}
`
The realtimeVolatility function includes the following options for managing the websocket interface.```
realtimeVolatility({
idleTimeout: number | undefined, // default: 10000 - how long to wait for inactivity before giving up
reconnect: boolean | undefined, // default: true - reconnect on disconnect
onError?: (error: Error) => void
})