How To Fetch CoinEx API With Access ID And Secret Key In Java Script?

I Trying To Fetch CoinEx API And Get Account Info But I Receive Error .

API Documentation :

API Invocation Description

Acquire Market Statistics

Inquire Account Info

Note : This Account Is Only For Test (Sharing Access ID And Secret Key In Public)

<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/md5.min.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>

Result : Signature error.



Read more here: https://stackoverflow.com/questions/67928331/how-to-fetch-coinex-api-with-access-id-and-secret-key-in-java-script

Content Attribution

This content was originally published by noob at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: