phemex api calls
This commit is contained in:
parent
00230fa01f
commit
fd813763c2
30
dabo/functions/phemex-api-call.sh
Normal file
30
dabo/functions/phemex-api-call.sh
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md
|
||||||
|
|
||||||
|
function phemex-api-call {
|
||||||
|
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
|
||||||
|
local method=$1
|
||||||
|
local call=$2
|
||||||
|
local params=$3
|
||||||
|
|
||||||
|
if [ -s /dabo/.phemex-secrets ]
|
||||||
|
then
|
||||||
|
. /dabo/.phemex-secrets
|
||||||
|
else
|
||||||
|
g_echo_error "No secrets file found"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${call}" | egrep -q "/account/" && local f_token="-H 'Authorization: Bearer ${API_TOKEN}'"
|
||||||
|
echo "curl -s -X ${method} --url https://api.phemex.com/${call} $f_token -H 'Accept: application/json' ${params}" >${g_tmp}/API_CMD
|
||||||
|
echo "curl -s -X ${method} --url https://api.phemex.com/${call} -H 'Accept: application/json'" >${g_tmp}/API_CMD_WO_KEY
|
||||||
|
g_runcmd g_retrycmd sh ${g_tmp}/API_CMD >${g_tmp}/API_CMD_OUT 2>&1
|
||||||
|
|
||||||
|
if egrep -q -i '^{"code":|error' ${g_tmp}/API_CMD_OUT
|
||||||
|
then
|
||||||
|
g_echo_error "$(cat ${g_tmp}/API_CMD_WO_KEY): $(cat ${g_tmp}/API_CMD_OUT)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user