Bitcoin Forum
December 11, 2017, 10:29:47 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Trade API btc-e.com  (Read 5934 times)
btc-e.com
Legendary
*
Offline Offline

Activity: 1694


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 // Биржа по автоматической торговле Bitcoin \ Litecoin \ Namecoin \ Novacoin <-> Exchange btc-e.com
1512988187
Hero Member
*
Offline Offline

Posts: 1512988187

View Profile Personal Message (Offline)

Ignore
1512988187
Reply with quote  #2

1512988187
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1512988187
Hero Member
*
Offline Offline

Posts: 1512988187

View Profile Personal Message (Offline)

Ignore
1512988187
Reply with quote  #2

1512988187
Report to moderator
miracle.max
Newbie
*
Offline Offline

Activity: 22


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

LTC: LePiC6JKohb7w6PdFL2KDV1VoZJPFwqXgY
BTC: 1BzHpzqEVKjDQNCqV67Ju4dYL68aR8jTEe
PoorGirl
Jr. Member
*
Offline Offline

Activity: 30



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

Any idea ?  Undecided

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

BTC-E.com API C++ Code: http://pastebin.com/YvxmCRL9
miracle.max
Newbie
*
Offline Offline

Activity: 22


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.

LTC: LePiC6JKohb7w6PdFL2KDV1VoZJPFwqXgY
BTC: 1BzHpzqEVKjDQNCqV67Ju4dYL68aR8jTEe
btc-e.com
Legendary
*
Offline Offline

Activity: 1694


View Profile WWW
August 04, 2012, 08:06:35 AM
 #5

nix way, файлы key и secret - ключ из профиля

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 // Биржа по автоматической торговле Bitcoin \ Litecoin \ Namecoin \ Novacoin <-> Exchange btc-e.com
miracle.max
Newbie
*
Offline Offline

Activity: 22


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.

LTC: LePiC6JKohb7w6PdFL2KDV1VoZJPFwqXgY
BTC: 1BzHpzqEVKjDQNCqV67Ju4dYL68aR8jTEe
miracle.max
Newbie
*
Offline Offline

Activity: 22


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?

LTC: LePiC6JKohb7w6PdFL2KDV1VoZJPFwqXgY
BTC: 1BzHpzqEVKjDQNCqV67Ju4dYL68aR8jTEe
miracle.max
Newbie
*
Offline Offline

Activity: 22


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. 

LTC: LePiC6JKohb7w6PdFL2KDV1VoZJPFwqXgY
BTC: 1BzHpzqEVKjDQNCqV67Ju4dYL68aR8jTEe
btc-e.com
Legendary
*
Offline Offline

Activity: 1694


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 // Биржа по автоматической торговле Bitcoin \ Litecoin \ Namecoin \ Novacoin <-> Exchange btc-e.com
grimd34th
Member
**
Offline Offline

Activity: 89



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: 604



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: 604



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: 173


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

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

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

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!