Crypto.com API - Create Order

186 Views Asked by At

Anyone have thoughts on Crypto.com API for create order.

I am having no luck. I can only get unauthorized. I cannot seem to find good code sample of what the final hmac string should be.

<cfset pl = "instrumentnameXLMUSDTquantity1000sideselltypemarket">

<cfset strp = '{"instrument_name":"XLM_USDT","quantity":1000,"side":"sell","type":"market"}'>

 <cfscript>

apiKey = "#cr_key#";
apiSecret = "#cr_s#";

hmacm = #req_path# & 121 & apikey & #pl# & #unixdatetimeNow.getTime()#;

CrHex = hmac(hmacm, apiSecret, "HmacSHA256");

theKeyBytes = charsetDecode(ApiSecret, "UTF-8");
crsign = lcase(hmac(hmacm, apiSecret, "HmacSHA256"));

newbody = serializeJSON({
"api_key": "#cr_key#",
"method": "#req_path#",
"id": 121,
"params": deserializeJSON(#strp#),
"nonce": #unixdatetimeNow.getTime()#, 
"sig": "#crsign#"
});

 </cfscript> 

HMACM STRING FOR ENCRYPT

private/create-order121qerX99999w75583kiSMqjpinstrumentnameXLMUSDTquantity1000sideselltypemarket1654206264743

  <CFHTTP METHOD="POST" URL="#base_api##req_path#" result="result">
  <cfhttpparam type="header" name="Content-Type" value="application/json">
  <cfhttpparam type="body" value="#newbody#">
  </cfhttp> 

If anyone knows a JAVASCRIPT version - I could push that as well. But wow. This exchange API is not fun.

0

There are 0 best solutions below