Get Bitcoin Price Using Bybit API in Bash

With Bybit API [1] it is possible to get public data (price, volume, last trading records) and also place own orders using API Key. All the next examples do not need API Key, because open public data is used here.

First, install jq for read json data and search in it to get only fields we need.

apt install jq


Bitcoin price in Spot trading from Bybit API. Ticker BTCUSDT info

This price is from latest finished orders.

echo BTCUSDT `curl -s '' | jq -r '.result.price'`

BTCUSDT 23203.03


Bitcoin price from order book: asks and bids

This price is that people are ready to buy or sell.

R='\033[0;31m' G='\033[0;32m' N='\033[0m' d=`curl -s '' | jq -r '.result'`; echo -e BTCUSDT ${R}Sell${N}: `echo $d | jq -r '.asks[][0]'` "\n"BTCUSDT $G Buy${N}: `echo $d | jq -r '.bids[][0]'`

BTCUSDT Sell: 23211.11 
BTCUSDT  Buy: 23211.1


All available trading pairs

curl -s '' | jq -r '.result[].name'


There are 266 pairs now.


Bitcoin Short price in Spot trading: BTC3SUSDT

echo BTC3SUSDT `curl -s '' | jq -r '.result.price'`

BTC3SUSDT 16.566


There are also "Inverse Perpetual", "USDT Perpetual", "Inverse Futures" markets and their API.


curl cannot verify certificates on Android

Also, I had a problem getting data via HTTPS on Android with curl:

curl ''

curl: (77) error setting certificate verify locations:
  CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs

First, I used option -k for curl does not check certificates. But then I fixed this with [2], need to install ca-certificates:

apt install ca-certificates



[1] Bybit API

[2] Curl error 77 problem with the SSL CA cert