API Reference

Along with apis, there is also websockets!

Websockets can be used to listen to real time events, such as price updates, orderbook updates etc.

To an high extent, pinging apis for static data on a high frequency introduces redundancy. Stats like prices, orderbook etc, only update if there is an activity on the same.

How about you get delivered real time updates instead 🤯

Here's a basic setup using socket.io

import { io } from "socket.io-client"

const socket = new io("wss://live.nftperp.xyz", { transports: ["websocket"] })

The events are as follows

TRADE

socket.on("TRADE", (data) => console.log(data))

This event is used to listen to trades, the data contains the trade info such as

  • amm
  • trader
  • markPrice
  • ...

💡 Use this event to listen to real time mark price updates (or anything else based on other props)

INDEX_PRICE

socket.on("INDEX_PRICE", (data) => console.log(data))

💡 Use this event to listen to real time index price updates

ORDER

socket.on("ORDER", (data) => console.log(data))

This event emits when the orderbook changes.

note: it just emits with the name of the amm of which orderbook changed, use this in combination with the orderbook endpoint to keep updated real time

💡 Use this event to listen to orderbook updates

FUNDING

socket.on("FUNDING", (data) => console.log)

💡 Use this event to listen to real time funding settlement