BTCMarkets / API

API
120 stars 30 forks source link

Is there any way to limit the number of orderbook entries? #200

Closed fatduckling closed 2 years ago

fatduckling commented 2 years ago

When I use the orderbook API, eg

https://api.btcmarkets.net/v3/markets/orderbooks?marketId=ALGO-AUD&marketId=BAT-AUD&marketId=BCH-AUD&marketId=BSV-AUD&marketId=BTC-AUD&marketId=COMP-AUD&marketId=ENJ-AUD&marketId=ETC-AUD&marketId=ETH-AUD&marketId=ETH-BTC&marketId=GNT-AUD&marketId=LINK-AUD&marketId=LTC-AUD&marketId=LTC-BTC&marketId=MCAU-AUD&marketId=OMG-AUD&marketId=POWR-AUD&marketId=USDT-AUD&marketId=XLM-AUD&marketId=XRP-AUD&marketId=XRP-BTC&

It returns the orderbook depth for the best 50 orders. Is it possible to only retrieve it for the first order only?

I need the price and volume of the best order only. If I use the ticker API, it doesn't provide the best bid/ask order's volume (it only shows price).

Thanks

martin-nginio commented 2 years ago

Hi @fatduckling

Thanks for your feedback.

You could use ticker API in order to get bestBid, bestAsk and also lastPrice per market, instead of using orderbook API.

Perhaps this API works for you?

https://api.btcmarkets.net/v3/markets/tickers?marketId=ALGO-AUD&marketId=BAT-AUD&marketId=BCH-AUD&marketId=BSV-AUD&marketId=BTC-AUD&marketId=COMP-AUD&marketId=ENJ-AUD&marketId=ETC-AUD&marketId=ETH-AUD&marketId=ETH-BTC&marketId=GNT-AUD&marketId=LINK-AUD&marketId=LTC-AUD&marketId=LTC-BTC&marketId=MCAU-AUD&marketId=OMG-AUD&marketId=POWR-AUD&marketId=USDT-AUD&marketId=XLM-AUD&marketId=XRP-AUD&marketId=XRP-BTC&

Regards, Martin

fatduckling commented 2 years ago

Hi @martin-nginio

I had to use the orderbook API instead of the ticker API because it has the volume of the best bid and best ask. The ticker API only has the price of the best bid/ask, but not the amount.

Any chance you can update the ticker API to also include the best bid/ask order's volume too?

Binance API has my expected behavior, eg: https://api.binance.com/api/v3/ticker/24hr?symbol=BTCAUD

They have bidPrice, askPrice, bidQty and askQty.

Thanks

martin-nginio commented 2 years ago

Thanks @fatduckling.

In that case, let me raise this with our dev team to be added to the development although I can't comment on timeline yet.

I think Orderbook API is a better place to cover what you need.

We can perhaps. introduce a new level (e.g. level = 0) and only return first bid, first ask, and corresponding order volumes in the same format as you mentioned in the original question.

Regards, Martin

martin-nginio commented 2 years ago

Hi @fatduckling

The following API should work and provide you with the top bid/ask and the same format as the other orderbooks: https://api.btcmarkets.net/v3/markets/orderbooks?marketId=BTC-AUD&marketId=ETH-AUD&level=0

We added a new level (level=0) that only returns top bid/ask orders.

This has been implemented but not documented yet. It will be added to out public documentation later on.

Thank you again for your feedback.

Regards, Martin

fatduckling commented 2 years ago

Hi @martin-nginio This is exactly what I was after, thank you!

I think this new API will be very beneficial to lot of users that are only interested in getting the best order details without reading the entire orderbook. I'm sure it should save a lot of bandwidth between BTC Markets servers and our servers. Thanks!