Hanji Docs
  • About Hanji
  • Trading
    • Order Book
    • Order Types
    • Fees
  • Architecture
    • Matching Engine
    • Prices and Precision
    • Gas Costs
  • Audits
  • For developers
    • API
      • Contract API
      • Common objects
      • HTTP API
      • Websocket API
    • SDK
      • HanjiClient
      • HanjiSpot
  • LP Vault
    • Overview
    • Hanji Vault
    • Single-Token LP Vaults
Powered by GitBook
On this page
  • Subscriptions
  • trades
  • Subscription parameters
  • Event data
  • userOrders
  • Subscription parameters
  • Event data
  • orderbook
  • Subscription parameters
  • Event data
  • userFills
  • Subscription parameters
  • Event data
  • candles
  • Subscription parameters
  • Event data
  • market
  • Subscription parameters
  • Event data
  1. For developers
  2. API

Websocket API

If you connect to the WebSocket endpoint, you can subscribe to some channels and receive updates about objects.

PreviousHTTP APINextSDK

Last updated 4 months ago

Updates come in the form of a full object and can substitute existing objects by their object identifier.

The common form of messages received is

{
    "channel": // channel name
    "data": // depends on the channel
}

In several subscriptions, specifically market, trades, userOrders, orderbook, userFills (in other words, except candles), the client receives history objects as events, which are similar to those from calling the corresponding HTTP API with the default limit parameter.

Subscriptions

trades

Subscription parameters

Parameter
Type
Description

channel

string "trades"

the channel name

market

string

a market contract address

Event data

userOrders

Subscription parameters

Parameter
Type
Description

channel

string "userOrders"

the channel name

market

string

a market contract address

user

string

a user address

Event data

orderbook

Subscription parameters

Parameter
Type
Description

channel

string "orderbook"

the channel name

market

string

a market contract address

aggregation

number

an order book level of aggregation

Event data

An object:

Property
Type
Description

aggregation

string represents an aggregation of the market

an order book aggregation level

levels

object with fields"asks" and "bids"

userFills

Subscription parameters

Parameter
Type
Description

channel

string "userFills"

the channel name

market

string

a market contract address

user

string

a user address

Event data

candles

Subscription parameters

Parameter
Type
Description

channel

string "candles"

the channel name

market

string

a market contract address

resolution

string

one of the candle object's resolutions

Event data

market

Subscription parameters

Parameter
Type
Description

channel

string "market"

the channel name

market

string

a market contract address

Event data

A object

An object.

Each field is a sorted array of order book objects; asks are sorted in ascending order by price, and bids are sorted in descending order.

An object with keys representing user addresses and values as arrays of objects.

An object with keys representing a resolution and the values being objects.

An array of objects.

trades
userOrders
orderbook
userFills
candles
market
trade
order
order fill
candle
market
level