Post
Topic
Board Service Discussion
Re: BTC-E Nonce Generation
by
Dirk83
on 18/05/2013, 15:47:30 UTC
I am testing code for the BTC-E trading platform, however, it seems like it can only process one API request per second, if I do more it gives an invalid nonce parameter error back.

It can only process one API request per unique nonce and your nonce is number of seconds since the Unix epoch, so you are changing your nonce only once per second. You are skipping the microseconds part of microtime() return. Please read: http://php.net/manual/en/function.microtime.php, or the quickest shortcut would be $req['nonce'] = (int) 10000*microtime(true);

I already tried generating a more complex nonce, but it didn't work.

Apparently it needs a nonce of exactly 10 numbers (this is mentioned nowhere however), which I now generate partly from the seconds and from the microseconds part:

$mt = explode(' ', microtime());
$req['nonce'] = substr($mt[1],-4).substr($mt[0], 2, 6);

Issue solved now, thanks for the reply.