Get info from Bitget.com using API in Bash.
You may need to install jq first:
apt install jq
1. Get all available currencies in Spot trading
/api/spot/v1/public/currencies
curl -s 'https://api.bitget.com/api/spot/v1/public/currencies' | jq .
curl -s 'https://api.bitget.com/api/spot/v1/public/currencies' | jq '.data[].coinName' | wc -l
359
There are 359 coins in Spot trading now.
2. Get Bitcoin Buy and Sell orders prices
/api/spot/v1/market/ticker
curl -s 'https://api.bitget.com/api/spot/v1/market/ticker?symbol=BTCUSDT_SPBL'
{
"code": "00000",
"msg": "success",
"requestTime": 0,
"data": {
"symbol": "BTCUSDT",
"high24h": "24275.57",
"low24h": "23970.4",
"close": "24009.38",
"quoteVol": "170267365.683",
"baseVol": "7015.0141",
"usdtVol": "170267365.682977",
"ts": "1660592484079",
"buyOne": "24009.32",
"sellOne": "24009.46"
}
}
SPBL - it is instrument type: "SP: Spot public channel SPBL Spot private channel"
Let's get onle necessary lines to get buy and sell orders prices:
R='\033[0;31m' G='\033[0;32m' N='\033[0m' d=`curl -s 'https://api.bitget.com/api/spot/v1/market/ticker?symbol=BTCUSDT_SPBL' | jq '.data'`; echo -e BTCUSDT ${R}Sell${N}: `echo $d | jq -r '.sellOne'` "\n"BTCUSDT $G Buy${N}: `echo $d | jq -r '.buyOne'`
BTCUSDT Sell: 24039.82;
BTCUSDT Buy: 24039.68
Links
1. Bitget API reference: https://bitgetlimited.github.io/apidoc/en/spot/#update-log