4
votes

I am pulling my hair out trying to query the CoinSpot API.

The endpoint for the Read Only API is: https://www.coinspot.com.au/api/ro

The documentation states:

All requests to the API will need to include the following security data.

Headers: key - Your API key generated from the settings page sign - The POST data is to be signed using your secret key according to HMAC-SHA512 method. Post Params: nonce - Any integer value which must always be greater than the previous requests nonce value.

I try to query the 'List My Balances' endpoint via: https://www.coinspot.com.au/api/ro/my/balances

However, the code I have formulated below always returns an error: "invalid/missing nonce".

I have tried so many different variations and approaches but it is always the same error.

require(httr)

key <- "68z...39k"
secret <- "71A...48i"

result <- POST("https://www.coinspot.com.au/api/ro/my/balances",
               body = list('nonce'=as.integer(as.POSIXct(Sys.time()))), add_headers("key"=key,"sign"=openssl::sha512("https://www.coinspot.com.au/api/ro/my/balances",key = secret)))

content(result)

Any help much appreciated.

1
did you find a fix for this? Im also having the same issue... - ayushlal
Does openssl::sha512 return a string? Looks like it needs to be a string of hex values. - Laurence Dougal Myers
@ayushlal - sadly I never found a solution for this problem. I ended up using Binance instead, as the REST API is well documented and easier to work with. There is an R package to interface with it, although it has some bugs as it is no longer maintained. DM me and I can help. - timothyjgraham
same issue at my end as well. Used postman to access but get the following error: {"status":"error","message":"invalid/missing nonce"} - raring sunny
Do they have any tech support that can help resolve this mystery? - raring sunny

1 Answers

1
votes

For me, I was missing the JSON string encoded postdata in the body, including the nonce. As soon as I added that, it started working.