0

I would like to use my Linux console to read Bitcoin price from specific exchange using one-liner command.

I were able to achieve that using Curl with the following command.

curl -sSL https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT | head -n 1 | sed "s|^.*,|$|" | sed "s|\(\.[0-9]$\)|\10|"

But I noticed a delay while retrieving the price and it's shown the price on the console wrongly.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250

1 Answers1

2

I see only minimal differences in the output of that command and the site's online ticker. If you need to have to minimise the delay, then don't put the output through such a long pipeline.

Instead, since the API returns a tiny JSON document, just have jq extract the price (if that's what you're after):

curl -sS URL | jq -r '.price'
Kusalananda
  • 320,670
  • 36
  • 633
  • 936