Having trouble fetching account information using the CoinEx API and encountering an error.
For more information on the API, please visit:
Note : This account is only for test purposes (Sharing access ID and secret key publicly).
<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/md5.js"></script>
<script>
let ServerTime=0;
let AccessID="61CFB9AB7F0B46B18F26EE2E3F155F4C";
let SecretKey="109E2A9E37DD4257D4C6DEDFE3F261A269EEB98DAA48B3E1";
let Signature=CryptoJS.MD5(SecretKey).toString().toUpperCase();
Process();
async function Process()
{
await MarketStatistics();
await AccountInfo(ServerTime,AccessID,SecretKey,Signature);
}
async function MarketStatistics()
{
let MarketStatistics_Fetch=await fetch("https://api.coinex.com/v1/market/ticker/all");
let MarketStatistics_JSON=await MarketStatistics_Fetch.json();
ServerTime=parseInt(MarketStatistics_JSON.data.date);
}
async function AccountInfo(ServerTime,AccessID,SecretKey,Signature)
{
let AccountInfo_Fetch=await fetch("https://api.coinex.com/v1/balance/info"+"?"+"access_id="+AccessID+"&"+"tonce="+ServerTime+"&"+"secret_key="+SecretKey,{method:"get",headers:{"authorization":Signature}});
let AccountInfo_JSON=await AccountInfo_Fetch.json();
alert(AccountInfo_JSON.message);
}
</script>
</html>
Outcome : Signature issue detected.