Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@volatility/volatility-ws

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volatility/volatility-ws

Documentation for Volatility WebSockets API

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Overview

The 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.

Websocket API Servers

NameEndpointPurpose
Productionwss://ws.prd.volatility.comFor production and consumer facing use.

Getting an API Key

To use our WebSocket API a valid API key is required. Here's how:

  1. Join our Discord.
  2. Go to the #collabland-join channel.
  3. Click "Let's go!".
  4. Click "Connect Wallet".
  5. Choose a wallet connection and connet your wallet.
  6. Click "Sign Message".
  7. Through your wallet, Sign the transaction. You should see a Wallet Connected! message.
  8. Return to Discord.
  9. Under COMMUNITY, you should now see a new channel called #labs-volatility-api. Go to this channel and request an API key.
  10. Someone from our team will DM you an API key within 72 hours.

Quick Start

Our API can be accessed through our npm package server-side or directly using the WebSocket Client API client-side.

If you clone this repository, you can run our example script in node by doing the following:

  1. In your terminal run:
npm install
  1. Add your API key as an environment variable. In your terminal run:
export VOLATILITY_API_KEY=<API_KEY>
  • Replace <API_KEY> with your API key our team provided you.
  1. In your terminal run:
ts-node src/example.ts

You can see the example script source code here.

Server Side Applications

Currently, this package only works on the server-side. A future release will support browser-based client-side applications.

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: "<API_KEY>"
})

// 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
})

Future Updates

  • Allow combining of indices.
  • Use of the API with browser-based client-side applications.

FAQs

Package last updated on 25 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc