bitkub / bitkub-official-api-docs

Official Documentation for Bitkub APIs
234 stars 204 forks source link

Get full orderbook for every product #136

Open lucasrothman opened 10 months ago

lucasrothman commented 10 months ago

I'm trying to get the full level 2 orderbook for every market, and then maintain a live version of the orderbook using the websocket.

For coinbase I would make a request:

// Request
{
    "type": "subscribe",
    "channels": ["level2"],
    "product_ids": [
        "ETH-USD",
        "BTC-USD"
    ]
}

and then the first response is the entire current orderbook for each product:

{
  "type": "snapshot",
  "product_id": "BTC-USD",
  "bids": [["10101.10", "0.45054140"]],
  "asks": [["10102.55", "0.57753524"]]
}

and then subsequent events are changes like the following:

{
  "type": "l2update",
  "product_id": "BTC-USD",
  "time": "2019-08-14T20:42:27.265Z",
  "changes": [
    [
      "buy",
      "10101.80000000",
      "0.162567"
    ]
  ]
}

This lets me always maintain the current orderbook for all products.

What's the best way to do this with Bitkub?

I tried first using the REST API to fetch the current orderbook for each market and then starting a separate websocket for each market to update the orderbook. However, when I then hit the REST API endpoint for the orderbook again and compare it against what I have, it seems different. Any help is appreciated, thanks!

fauz-ks commented 9 months ago

@lucasrothman any update for orderbook ws handle method?