Bitcoin Forum
November 16, 2024, 04:58:32 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: Trade API btc-e.com  (Read 6000 times)
btc-e.com (OP)
Legendary
*
Offline Offline

Activity: 1694
Merit: 1002


View Profile WWW
August 02, 2012, 03:04:28 AM
 #1

Trade API

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

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

Bitcoin \ Litecoin \ Namecoin \ Novacoin <-> Exchange btc-e.com

BTC-E.com // Биpжa пo aвтoмaтичecкoй тopгoвлe Bitcoin \ Litecoin \ Namecoin \ Novacoin <-> Exchange btc-e.com
miracle.max
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
August 03, 2012, 04:16:48 AM
 #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
PoorGirl
Newbie
*
Offline Offline

Activity: 30
Merit: 0



View Profile
August 04, 2012, 02:35:50 AM
 #3

Any idea ?  Undecided

https://bitcointalk.org/index.php?topic=40889.msg1077256#msg1077256
miracle.max
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
August 04, 2012, 04:54:12 AM
 #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.
btc-e.com (OP)
Legendary
*
Offline Offline

Activity: 1694
Merit: 1002


View Profile WWW
August 04, 2012, 08: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:

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

Bitcoin \ Litecoin \ Namecoin \ Novacoin <-> Exchange btc-e.com

BTC-E.com // Биpжa пo aвтoмaтичecкoй тopгoвлe Bitcoin \ Litecoin \ Namecoin \ Novacoin <-> Exchange btc-e.com
miracle.max
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
August 04, 2012, 05: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.
miracle.max
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
August 04, 2012, 10: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?
miracle.max
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
August 04, 2012, 11: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. 
btc-e.com (OP)
Legendary
*
Offline Offline

Activity: 1694
Merit: 1002


View Profile WWW
August 05, 2012, 09:21:18 AM
 #9

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

Bitcoin \ Litecoin \ Namecoin \ Novacoin <-> Exchange btc-e.com

BTC-E.com // Биpжa пo aвтoмaтичecкoй тopгoвлe Bitcoin \ Litecoin \ Namecoin \ Novacoin <-> Exchange btc-e.com
grimd34th
Member
**
Offline Offline

Activity: 89
Merit: 10



View Profile
August 05, 2012, 06: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
qxzn
Hero Member
*****
Offline Offline

Activity: 609
Merit: 506



View Profile
October 02, 2012, 06: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
qxzn
Hero Member
*****
Offline Offline

Activity: 609
Merit: 506



View Profile
October 02, 2012, 06: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.
kushti
Full Member
***
Offline Offline

Activity: 317
Merit: 103


View Profile WWW
April 17, 2013, 01:51:18 PM
 #13

I released Scala client for Trade API - https://github.com/kushti

Ergo Platform core dev. Previously IOHK Research / Nxt core dev / SmartContract.com cofounder.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!