Author

Topic: Trade API btc-e.com (Read 6000 times)

full member
Activity: 317
Merit: 103
April 17, 2013, 08:51:18 AM
#13
I released Scala client for Trade API - https://github.com/kushti
hero member
Activity: 609
Merit: 506
October 02, 2012, 01:17:32 PM
#12
what is the interpretation of the status field on orders?

{
   "success":1,
   "return":{
      "1081672":{
         "type":1,
         "amount":1.00000000,
         "currency":"BTC",
         "desc":"BTC Payment",
         "status":2,
         "timestamp":1342448420
      }
   }
}

it can also be 0 and presumably 1

Sorry, that was a paste of a transaction, not an order. But I guess that's ok -- I'm also wondering what the status field means on transactions.
hero member
Activity: 609
Merit: 506
October 02, 2012, 01:13:30 PM
#11
what is the interpretation of the status field on orders?

{
   "success":1,
   "return":{
      "1081672":{
         "type":1,
         "amount":1.00000000,
         "currency":"BTC",
         "desc":"BTC Payment",
         "status":2,
         "timestamp":1342448420
      }
   }
}

it can also be 0 and presumably 1
member
Activity: 89
Merit: 10
August 05, 2012, 01:27:15 PM
#10
made a python class

http://pastebin.com/ugMqPkEe

ran with:
Code:
import tapi

client = tapi.tradeapi('MYKEY','MYSECRET')

print client.getInfo()

put in some groundwork for expansion
legendary
Activity: 1694
Merit: 1002
August 05, 2012, 04:21:18 AM
#9
newbie
Activity: 22
Merit: 0
August 04, 2012, 06:26:42 PM
#8
In case I'm just doing something stupid here: When I attempt to sell LTC for BTC, I get a "You incorrectly entered one of the fields" message, but selling LTC for USD works just fine.  Here are the parameters for each:

LTC->USD: nonce=1344119831&amount=1.000000&rate=0.045100&pair=ltc_usd&type=sell&method=Trade

LTC->BTC: nonce=1344119854&amount=1.000000&rate=0.004570&pair=ltc_btc&type=sell&method=Trade

Anybody know what's going on here?
After chatting with dev at BTC-e, it turns out the number of decimal places they will accept is limited.  It seems that I could have 5 digits after the decimal for LTC->BTC trades, and 4 for LTC->USD, but I'm not sure if that's the official limit. 
newbie
Activity: 22
Merit: 0
August 04, 2012, 05:46:06 PM
#7
In case I'm just doing something stupid here: When I attempt to sell LTC for BTC, I get a "You incorrectly entered one of the fields" message, but selling LTC for USD works just fine.  Here are the parameters for each:

LTC->USD: nonce=1344119831&amount=1.000000&rate=0.045100&pair=ltc_usd&type=sell&method=Trade

LTC->BTC: nonce=1344119854&amount=1.000000&rate=0.004570&pair=ltc_btc&type=sell&method=Trade

Anybody know what's going on here?
newbie
Activity: 22
Merit: 0
August 04, 2012, 12:22:52 PM
#6
So (if I read btc-e's command correctly) in C you can just use the value returned by the time() function (in time.h) as the nonce, or int(time.time()) in the Python script, as long as you don't want to make more than one API call per second.
legendary
Activity: 1694
Merit: 1002
August 04, 2012, 03:06:35 AM
#5
nix way, фaйлы key и secret - ключ из пpoфиля

echo -n "`date '+%s'`">nonce && echo -n "method=getInfo&nonce=`cat nonce`" | openssl dgst -sha512 -hmac `cat secret` > sign && curl -d "method=getInfo&nonce=`cat nonce`" -H "Key:`cat key`" -H "Sign:`cat sign`" https://btc-e.com/tapi

php:

$t = time();
$h = hash_hmac('sha512','method=getInfo&nonce='.$t, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); //xx...xx secret

$url='https://btc-e.com/tapi';

$data = "method=getInfo&nonce=$t";
$tuCurl = curl_init();
curl_setopt($tuCurl, CURLOPT_URL, $url);
curl_setopt($tuCurl, CURLOPT_VERBOSE, 1);
curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($tuCurl, CURLOPT_POST, 1);
curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($tuCurl, CURLOPT_POSTFIELDS, $data);
curl_setopt($tuCurl, CURLOPT_HTTPHEADER,
 array("Key: AAAAAAAA-AAAAAAAA-AAAAAAAA-AAAAAAAA-AAAAAAAA",
 "Sign: $h"));

$tuData = curl_exec($tuCurl);
curl_close($tuCurl);

echo $tuData;
?>
newbie
Activity: 22
Merit: 0
August 03, 2012, 11:54:12 PM
#4
I think the only time I've seen that nonce message is when I've accidentally called the API more than once with the same nonce.  As far as I can tell, it remembers forever the largest nonce it's seen so far, so you have to make sure to increment even if you're just calling the API for testing.
newbie
Activity: 30
Merit: 0
newbie
Activity: 22
Merit: 0
August 02, 2012, 11:16:48 PM
#2
In case it's useful to somebody, here's a Python example showing how to call the getInfo method (adapted from jeremy88's PHP snippet in the BTC-e comments): http://pastebin.com/ec11hxcP
legendary
Activity: 1694
Merit: 1002
Jump to: