Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: btc-e.com on August 02, 2012, 03:04:28 AM



Title: Trade API btc-e.com
Post by: btc-e.com on August 02, 2012, 03:04:28 AM
Trade API

Description - https://btc-e.com/api/documentation

https://btc-e.com/news/83


Title: Re: Trade API btc-e.com
Post by: miracle.max on August 03, 2012, 04:16:48 AM
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


Title: Re: Trade API btc-e.com
Post by: PoorGirl on August 04, 2012, 02:35:50 AM
Any idea ?  :-\

https://bitcointalk.org/index.php?topic=40889.msg1077256#msg1077256


Title: Re: Trade API btc-e.com
Post by: miracle.max on August 04, 2012, 04:54:12 AM
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.


Title: Re: Trade API btc-e.com
Post by: btc-e.com on August 04, 2012, 08:06:35 AM
Any idea ?  :-\

https://bitcointalk.org/index.php?topic=40889.msg1077256#msg1077256
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:

<?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;
?>


Title: Re: Trade API btc-e.com
Post by: miracle.max on August 04, 2012, 05:22:52 PM
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.


Title: Re: Trade API btc-e.com
Post by: miracle.max on August 04, 2012, 10:46:06 PM
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?


Title: Re: Trade API btc-e.com
Post by: miracle.max on August 04, 2012, 11:26:42 PM
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. 


Title: Re: Trade API btc-e.com
Post by: btc-e.com on August 05, 2012, 09:21:18 AM
Added examples of trade API

https://btc-e.com/api/documentation

PHP: http://pastebin.com/DDqAx7VU
Python: http://pastebin.com/ec11hxcP by miraclemax
Java: http://pastebin.com/jyd9tACF by dApZoKntut
C#: http://pastebin.com/TSdGbfBs by DmT


Title: Re: Trade API btc-e.com
Post by: grimd34th on August 05, 2012, 06:27:15 PM
made a python class

http://pastebin.com/ugMqPkEe (http://pastebin.com/ugMqPkEe)

ran with:
Code:
import tapi

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

print client.getInfo()

put in some groundwork for expansion


Title: Re: Trade API btc-e.com
Post by: qxzn on October 02, 2012, 06:13:30 PM
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


Title: Re: Trade API btc-e.com
Post by: qxzn on October 02, 2012, 06:17:32 PM
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.


Title: Re: Trade API btc-e.com
Post by: kushti on April 17, 2013, 01:51:18 PM
I released Scala client for Trade API - https://github.com/kushti (https://github.com/kushti)