Alcor
  • Alcor.exchange
  • What is Alcor Exchange?
  • Home Page Overview
    • Swap
      • Swap Charts
      • Add Liquidity
      • Manage Liquidity
    • Markets
      • Market Exchange
        • Order Books
        • Graph
        • Open Orders
        • Placing Trades
    • OTC
    • NFT
    • Wallet
  • Developers API
    • Amm Swap Contract API
      • Formulas
      • Contracts
      • Examples
    • Market creation
      • Open new market
    • Contract actions
    • Contract Tables
    • API
      • Markets API
      • Account
      • WebSocket
      • Node API
    • Public Alcor Data Access
  • Alcor Swap
    • Referral / Custom Market Fee
    • Introduction
    • Swap Page
    • Locking Liquidity
    • Providing liquidity
      • How to Add Liquidity on Alcor Exchange
    • Ranges: Everything you need to know
      • How to set a Range for your Liquidity position
    • Pool Page
    • Liquidity Provider FAQ
    • Concentrated liquidity FAQ
    • AlcorSwap v2 Price Oracles
      • Alcor Price Oracle vs DelphiOracle
      • Expanding Price Availability with RAM Purchase
      • How to Use Alcor Price Oracle
  • Alcor Farms: Unlocking DeFi Opportunities
    • Creating Farm Incentives - Quick Tutorial
    • Project Farms Unique Link
    • Technical details
  • LSW- Liquid Staked WAX
    • How it works
    • Exchange rate
    • Withdrawal process
  • Adding Token Information
    • Token logo
    • USD Price
  • Swap Widget
    • Swap Chart Widget
  • Networks Features
    • WAX
      • Alcor USDT
  • Additional Docs
  • Definitions
  • FAQ
    • Does Alcor Exchange Have Fees?
    • Whats the difference between using Swap, Market Trade, and OTC?
    • What is a liquidity Pool?
  • Social Media/Contact
Powered by GitBook
On this page

Was this helpful?

  1. Developers API
  2. API

WebSocket

WebSocket API

Alcor Exchange using Socket.IO for interact via WebSocket technology.

There are two commands for subscribing to and channel with specific information.

  1. subscribe: Subscribing for an specific room.

  2. unsubscribe: Unsubscribe from sprcific room.

Available rooms, and params that they receive.

  1. deals: chain, market. -> Subscribe to new deals. (first update will be last 200 deals).

  2. ticker: chain, market, resolution. -> Subscribe to chart updates.

  3. account: chain, name. -> Subscribe to account notifications. (only order match for now)

  4. orderbook: chain, side(sell/buy), market(id). -> Subscribe to orderbook updates. (first update is full order book state)

Currect events to receive:

  • match: Account new match

  • orderbook_sell: new orderbook update on sell side

  • orderbook_buy: new orderbook update on sell buy

  • new_deals: update on new deal on specific market

Example of connection:

import { io } from 'socket.io-client'
const socket = io('https://alcor.exchange')

// Subscribe to deals
socket.emit('subscribe', { room: 'deals', params: { chain: 'wax', market: 26 } })

// Unsubscribe from deals (will unsubscribe from all markets)
socket.emit('unsubscribe', { room: 'deals', params: { chain: 'wax' } })

// Subscribe to buy orderbook of 26 (TLM on wax) market.
socket.emit('subscribe', { room: 'orderbook', params: { chain: 'wax', market: 26, side: 'buy' } })

// Unsubscribe from orderbook (all, buy and sell)
socket.emit('unsubscribe', { room: 'orderbook', params: { chain: 'wax', market: 26 } })

// Subscribe to account updates
socket.emit('subscribe', { room: 'account', params: { chain: 'wax', 'name': 'avra.pro' } })


// Listen for updates

// On account new match
socket.on('match', match => { ... })

// On orderbook update (bid for example)
socket.on('orderbook_buy', bids => { ... })

// On new deals of market
socket.on('new_deals', deals => { ... })
PreviousAccountNextNode API

Last updated 3 years ago

Was this helpful?