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.

closed as unclear what you're asking by Rui F Ribeiro, Sparhawk, jimmij, X Tian, Stephen Kitt Feb 12 at 17:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • what does "shown wrongly" mean -- graphically garbled, or the wrong data, or ...? – Jeff Schaller Feb 11 at 22:52
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'

Not the answer you're looking for? Browse other questions tagged or ask your own question.