better coingecko error handling - too many requests
This commit is contained in:
parent
d670137769
commit
a2dc3b718a
@ -1,7 +1,15 @@
|
||||
function get_coingecko_data {
|
||||
# get data from coingecko
|
||||
echo "curl -s -X 'GET' \"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=250&page=1&sparkline=false&price_change_percentage=1h,24h,7d,14d,30d,1y\" -H 'accept: application/json'" >COINGECKO_GET_ASSETS_CMD
|
||||
g_runcmd g_retrycmd sh COINGECKO_GET_ASSETS_CMD >COINGECKO_GET_ASSETS_CMD_OUT || return 1
|
||||
g_runcmd g_retrycmd sh COINGECKO_GET_ASSETS_CMD >COINGECKO_GET_ASSETS_CMD_OUT_TMP || return 1
|
||||
local f_test_query=$(jq -r ".[] |select(.symbol==\"btc\")|\"\\(.current_price)\"" COINGECKO_GET_ASSETS_CMD_OUT_TMP)
|
||||
if g_num_valid_number ${f_test_query}
|
||||
then
|
||||
mv COINGECKO_GET_ASSETS_CMD_OUT_TMP COINGECKO_GET_ASSETS_CMD_OUT
|
||||
else
|
||||
find COINGECKO_GET_ASSETS_CMD_OUT -mmin +${LOOP_INTERVAL} && g_echo_warn "Coingecko data older then ${LOOP_INTERVAL}s: $(ls -l COINGECKO_GET_ASSETS_CMD_OUT)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
[ ${FULL_LOOP} == 0 ] && return 0
|
||||
if [ -s COINGECKO_GET_ASSETS_CMD_OUT ] && grep -q "market_cap_rank" COINGECKO_GET_ASSETS_CMD_OUT
|
||||
|
Loading…
Reference in New Issue
Block a user