Coder Social home page Coder Social logo

api's People

Contributors

2pd avatar jarrodcrane avatar justin-ngin avatar martin-nginio avatar martinbajalan avatar michaelstewart avatar moneroexamples avatar nolim1t avatar tennantje avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api's Issues

include dummy private key in authentication example

Hi,

it would be great if you could update your authentication sample with a dummy private key along with a string to sign and the expected signature.

I am getting a authentication failed error, but have no way of knowing whether it's my signature or something else.

Thanks!

500 Internal Server Error when following Authentication Example

Hi,

I think I am successfully authenticating because I get a different message when authentication fails. But I am still getting an error.

I am using libcurl with C++. Here is the verbose output:

`* Trying 104.20.108.25...

  • TCP_NODELAY set
  • Connected to api.btcmarkets.net (104.20.108.25) port 443 (#0)
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@strength
  • successfully set certificate verify locations:
  • CAfile: /etc/ssl/certs/ca-certificates.crt
    CApath: none
  • SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
  • ALPN, server accepted to use http/1.1
  • Server certificate:
  • subject: OU=Domain Control Validated; OU=PositiveSSL Multi-Domain; CN=ssl507574.cloudflaressl.com
  • start date: Jul 31 00:00:00 2017 GMT
  • expire date: Feb 6 23:59:59 2018 GMT
  • subjectAltName: host "api.btcmarkets.net" matched cert's "*.btcmarkets.net"
  • issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO ECC Domain Validation Secure Server CA 2
  • SSL certificate verify ok.

POST /order/history HTTP/1.1
Host: api.btcmarkets.net
Accept: "application/json"
User-Agent: "curl/7.55.1"
Accept-Charset: "UTF-8"
Content-Type: "application/json"
apikey: "0f399fe6-9eb7-427d-9ef3-aaa5750fa2e6"
timestamp: "1506078958237"
signature: "7aE7j4pedN7ba6uPsF3TKbiJ7iGtApBN0pA0lK+zXop+8icltEPn6cZnGFsuBmM4Iy2FCozxcRLwZOu2rEzE9Q=="
Content-Length: 61

  • upload completely sent off: 61 out of 61 bytes
    < HTTP/1.1 500 Internal Server Error
    HTTP/1.1 500 Internal Server Error
    < Date: Fri, 22 Sep 2017 11:15:58 GMT
    Date: Fri, 22 Sep 2017 11:15:58 GMT
    < Content-Type: text/html
    Content-Type: text/html
    < Transfer-Encoding: chunked
    Transfer-Encoding: chunked
    < Connection: keep-alive
    Connection: keep-alive
  • Added cookie __cfduid="d442fde3cc016262495b4bc48957b2dc61506078958" for domain btcmarkets.net, path /, expire 1537614958
    < Set-Cookie: __cfduid=d442fde3cc016262495b4bc48957b2dc61506078958; expires=Sat, 22-Sep-18 11:15:58 GMT; path=/; domain=.btcmarkets.net; HttpOnly
    Set-Cookie: __cfduid=d442fde3cc016262495b4bc48957b2dc61506078958; expires=Sat, 22-Sep-18 11:15:58 GMT; path=/; domain=.btcmarkets.net; HttpOnly
    < Server: cloudflare-nginx
    Server: cloudflare-nginx
    < CF-RAY: 3a24d97268b465c9-SYD
    CF-RAY: 3a24d97268b465c9-SYD

<

<title>Error</title> An error occured. Please contact [email protected] <script>!function(e,t,r,n,c,a,l){function i(t,r){return r=e.createElement('div'),r.innerHTML='',r.childNodes[0].getAttribute('href')}function o(e,t,r,n){for(r='',n='0x'+e.substr(t,2)|0,t+=2;t-1&&(a.href='mailto:'+o(a.href,t+l.length))}catch(e){}for(c=e.querySelectorAll('.__cf_email__'),n=0;n * Connection #0 to host api.btcmarkets.net left intact `

Also here is my code (sorry that it is messy):

`#include
#include
#include
#include
#include
#include

#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>

#include <curl/curl.h>

#include <unistd.h>

typedef long long ll;

char *base64(const unsigned char *input, int length)
{
BIO *bmem, *b64;
BUF_MEM *bptr;

b64 = BIO_new(BIO_f_base64());
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
bmem = BIO_new(BIO_s_mem());
b64 = BIO_push(b64, bmem);
BIO_write(b64, input, length);
BIO_flush(b64);
BIO_get_mem_ptr(b64, &bptr);

char *buff = (char *)malloc(bptr->length+1);
memcpy(buff, bptr->data, bptr->length);
buff[bptr->length] = 0;

BIO_free_all(b64);

return buff;
}

char *unbase64(const unsigned char *input, int length)
{
BIO *b64, *bmem;

char *buffer = (char *)malloc(length);
memset(buffer, 0, length);

b64 = BIO_new(BIO_f_base64());
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
bmem = BIO_new_mem_buf(input, length);
bmem = BIO_push(b64, bmem);

BIO_read(bmem, buffer, length);

BIO_free_all(bmem);

return buffer;
}

const char* key = "private key goes here";

//const char* data = "abc";

// timestamp in ms
ll timestamp() {
return std::chrono::duration_caststd::chrono::milliseconds(std::chrono::system_clock::now().time_since_epoch()).count();
}

//signs a string
std::string signature(std::string tosign) {
char* binaryKey = unbase64(
reinterpret_cast<const unsigned char *>(key),
strlen(key)
);

unsigned char md[64];
unsigned int md_len;
HMAC(
		EVP_sha512(),
		reinterpret_cast<const unsigned char*>(key),
		strlen(key),
		reinterpret_cast<const unsigned char*>(tosign.c_str()),
		strlen(tosign.c_str()),
		md,
		&md_len
	);

free(binaryKey);

char* b64 = base64(md, md_len);

std::string result(b64);
free(b64);
return result;

}

int main() {
curl_global_init(CURL_GLOBAL_SSL);

/*
char* binary = unbase64(reinterpret_cast<const unsigned char*>(key), strlen(key));
char* encoded = base64(reinterpret_cast<unsigned char*>(binary), strlen(binary));
printf("%s\n", encoded);
printf("%s\n", key);
printf("%d\n", strlen(key));

free(binary);
free(encoded);

std::cout << timestamp() << std::endl;

*/
std::string timestampString = std::to_string(timestamp());

const char* body = "{\"currency\":\"AUD\",\"instrument\":\"BTC\",\"limit\":10,\"since\":null}";

std::string tosign = (std::string)"/order/history" + "\n" + timestampString + "\n" + body;//"{\"currency\":\"AUD\", \"instrument\":\"BTC\", \"limit\":\"10\"}";

//std::cout << tosign << '\n' << signature(tosign) << '\n';


CURL* easyhandle = curl_easy_init();

curl_easy_setopt(easyhandle, CURLOPT_HEADER, 1);
curl_easy_setopt(easyhandle, CURLOPT_VERBOSE, 1);

curl_easy_setopt(easyhandle, CURLOPT_COOKIEFILE, "");

const char* url = "https://api.btcmarkets.net/order/history";
curl_easy_setopt(easyhandle, CURLOPT_URL, url);

struct curl_slist *headers=NULL;
headers = curl_slist_append(headers,
		"Accept: \"application/json\"");
headers = curl_slist_append(headers,
		"User-Agent: \"curl/7.55.1\"");
headers = curl_slist_append(headers,
		"Accept-Charset: \"UTF-8\"");
headers = curl_slist_append(headers,
		"Content-Type: \"application/json\"");
headers = curl_slist_append(headers,
		"apikey: \"public key goes here\"");
headers = curl_slist_append(headers,
		("timestamp: \"" + timestampString +"\"").c_str());
headers = curl_slist_append(headers,
		("signature: \"" + signature(tosign) + "\"").c_str());

//const char* body = "{\"currency\":\"AUD\", \"instrument\":\"BTC\", \"limit\":\"10\"}";

/* post binary data */
curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDS, body);

/* set the size of the postfields data */
curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDSIZE, strlen(body));

/* pass our list of custom made headers */
curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, headers);

curl_easy_perform(easyhandle); /* post away! */
//usleep(5000);

curl_slist_free_all(headers); /* free the header list */

curl_global_cleanup();

}`

This is my compile command (my file is called test.cpp):

g++ -std=c++17 -Wall -Wshadow test.cpp -o test -lcrypto -lcurl

Request Limits

Hi, does the request limit refer to all request types (i.e. 25 order create/ cancel/ detail etc. requests per 10 seconds) OR does it apply individually for each request- i.e. can make 25 order creates per 10 seconds as well as 25 order cancels etc.

Custom API Needed???

Im far from a developer, but in order to run my Bitcoin ATM the way id like , i would have/like to give a third party access to place orders but wish to deny them the potential to withdraw funds?

Can someone assist me in this area????

Vinnie

No info on Market order type?

On the Trading API there are no examples of the Market order type, nor whether the price is required.

If you're creating a Market order and have $100 AUD to spend, why do you need to enter volume?

If you're creating a Market order and have 1 Bitcoin to sell, why do you need to enter the price?

Surely these are optional? If not, I'd appreciate seeing a sample JSON request for a Market order.

edit: Please and thank you :)

POST requests not authenticating in PHP

Hi there,

Having trouble figuring out why my POST request is returning an Authentication failed error. I took the code from the previous post and changed method to POST and added content which was the request data (in json)

public function history($count = 10, $since = 0 )
{
	
	$method = '/order/history';
    $data = [
        'currency' => 'AUD',
        'instrument' => 'BTC',
        'limit' => $count,
        'since' => $since ,
    ];
	
	$secret_key_encoded = base64_decode($this->secret);

	$nonce = round(microtime(true) * 1000); 

    // build query string

	$msg = $method. "\n" . $nonce . "\n";
	if(count($data)) {
		$data = json_encode($data). "\n";
		$msg .= $data;
	}
	
	echo "Message is:\n" . $msg;

	$encodedMsg =   hash_hmac('sha512', $msg, $secret_key_encoded, true);
	$base64Msg = base64_encode($encodedMsg); 
	
	echo "Encoded Message is: \n" . $base64Msg . "<br>\n";
	
	// Create a stream
	$opts = array(
	  'http'=>array(
			'method'=>"POST",
			'header'=>      "Accept: */*\r\n" .
							"Accept-Charset: UTF-8\r\n" .
							"Content-Type: application/json\r\n" .
							"apikey: " . $this->key . "\r\n" .
							"timestamp: " . $nonce . "\r\n" .
							"User-Agent: btc markets php client\r\n" .
							"signature: " . $base64Msg . "\r\n",
			'content'=> $data
	  )
	);

	$context = stream_context_create($opts);

	var_dump($opts);
            echo "\n\n";
	// Open the file using the HTTP headers set above
	$response = file_get_contents('https://api.btcmarkets.net'.$method, false, $context);

	print_r($response);
    if ($response === false)  {
        return false;
    }
    
    $result = json_decode($response, true);
    if (!$result) {
        return false;   
    }                
    
    return $result;
}	

What are the correct units for creating an API order for ETH in AUD?

Hi,

i'm writing an api order client. What units are ETH orders specified in? is it Wei?

Background:

try { // input parameters for creating a new account. data is posted via https String postData = "{\"currency\":\"AUD\",\"instrument\":\"BTC\",\"price\":13000000000,\"volume\":10000000,\"orderSide\":\"Bid\",\"ordertype\":\"Limit\",\"clientRequestId\":\"1\"}";
In the bitcoin example here, the price and volume have high values, probably 'satoshi' or multiples of 0.00000001 btc:

13000000000 * 0.00000001 = 130 AUD
10000000 * 0.00000001 = 0.1 BTC

For ETH, units are normally Wei (1.000.000.000.000.000.000 wei = 1 ETH), does this mean I need to multiply both AUD price and volume fields with 1.000.000.000.000.000.000?

Thanks,

Simon

Transaction Address creation

We are planning to create a system, should get the user coin value and send to address.

Looking for address for each transaction.

Please help me how to achieve this using BTC Market API.

Buy/Sell Side in Trade History

Is there a way to extract which side a trade transaction occurred on? Currently only the amount, trade ID, price, and date are shown. Is there a planned upgrade to provide this information?

websockets for python

Is there documentation on how to get websockets working for python with market data? I notice websocket sample codes for javascript, but also note that the address is https://socket.btcmarkets.net/ rather than wss://socket.btcmarkets.net or ws://socket.btcmarkets.net .

Been at it for a good number of days and any help is appreciated.

currency pairs

Does the API support bids and asks between currency pairs? Looks like it only supports AUD as a currency.

Account balance Api Question

Hello BTCmarket Development team.

I have noticed that you have recently changed the account balance JSON response to now include a new section 'pendingFunds'.

Is this pendingFunds information only supposed to show funds incoming when we are depositing money/ funds leaving when we are withdrawing money, or will it change when we are selling and buying crypto within the exchange?

Also how do we discern weather this pendingfunds value is incoming funds or leaving funds.

Thanks

Authentication Error on 'order/create' and 'tradingfees' endpoints only

Hi,

I have been successfully using the BTC Markets API for a while, but when I attempt to use either of the above endpoints I always get an authentication failure. I am signing the requests consistently and always using this code;

ssl_sign = OpenSSL::HMAC.digest('sha512', Base64.decode64(key), message)
Base64.encode64(ssl_sign).to_s.gsub("\n",'')

For the trading fee endpoint, for example, I set:

URI: /account/ETH/AUD/tradingfee
timestamp: [current time]
signature: [the base64 encoded signature]

And I always get:

@Body="{"success":false,"errorCode":1,"errorMessage":"Authentication failed."}"

So I am a bit lost on why I am hitting this error on these endpoints only. Do I need special API access to use these methods perhaps?

Thanks for your help!
Ben

non related historical data for a given instrument

Hi guys, Is it possible to query historical data using the API that is not directly related to an account, in short, all transaction data/log for a given instrument over period of time? eg. I wish to build my own historical graphs - Stu

Unexpected results from /order/trade/history endpoint

I'm getting unexpected results when comparing the API results with the following ETH/AUD trades from my account Trade History on the website.

Trade IDs:

533884871 <-- oldest
541239695
630427950
638544890
656555233
661178288 <-- newest

I want to be able to query x number of trades made after a specified trade ID.
For example, the request I've used to get my 2 oldest trades is:
{ currency: 'AUD', instrument: 'ETH', limit: 2, since: 533884871 } <-- oldest trade ID

I'm expecting this to return the trades with IDs:

533884871 <-- oldest
541239695

However it returns the 2 newest trades instead:

661178288 <-- newest
656555233

Is the trade ID I'm passing in as the 'since' parameter the correct ID? I noticed in the sample request here the length of the trade ID is 11 digits, whereas the trade ID I'm passing in is only 9 digits long.

Create order failed

Hi

I am trying to create a buy order via the API, I have created the following request to buy 4 LTC at the price of 0.00980147 BTC:
{"currency":"BTC","instrument":"LTC","price":980147,"volume":400000000,"orderSide":"Buy","ordertype":"Limit","clientRequestId":"abc"}
I got the following response:
{"success":false,"errorCode":3,"errorMessage":"Invalid argument.","id":0,"clientRequestId":"abc"}

Can you please let me know what was wrong in the request?

Thanks.

withdraw api

Is there, or when will there, be an API for withdrawing and depositing to our accoutns?

error with order history?

I've noticed the API recently (must've been within past two months) seems to no longer give me correct results for my order history:
I send this:
"{"currency":"AUD","instrument":"BTC","limit":15,"since":0}"
And my response is:
"{"success":true,"errorCode":null,"errorMessage":null,"orders":[]}"
Which is not correct. I have some orders!

Authentication example

I'm having issues getting the API authentication to work on my IDE. Could someone please provide an example of the values of a given call for each step of the process.

For example, if we use the values from the Authentication example page:

URI: /order/history
timestamp: 1378818710123
request body: {"currency":"AUD", "instrument":"BTC", "limit":"10"}

Let's say a user authenticates with the following private key (this is just a random string i banged out):

6dhAuK/bHWU2mA4kL3B8s34HnjSHu8nuBUIb7sNJKI3buh7dsBNUIcb7ghnjrE+Edm6Vf3CGYImk9s7bsay5gv==

what would the generated signature be in this case? I really just want to check that I am generating the correct key and that my authentication failure is from this or if I need to be looking elsewhere.

Authentication failure with POST requests

The java sample code provided doesn't work!
I modified a little bit (Accept header) as per wiki and managed to get it working for the GET /account/balance. However, the POST requests return Authentication Failed.

Please find the attached file derived from the PlaceOrder.java that tests the above cases.

package net.btcmarkets.api.sample;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.util.EntityUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

public class ApiClient {
    private static final String API_KEY = "replace-with-api-key";
    private static final String PRIVATE_KEY = "replace with private key";

    public static String BASEURL = "https://api.btcmarkets.net"; //"http://localhost:8080";// ;
    private static String ORDER_CREATE_PATH = "/order/open";
    private static final String APIKEY_HEADER = "apikey";
    private static final String TIMESTAMP_HEADER = "timestamp";
    private static final String SIGNATURE_HEADER = "signature";
    private static final String ENCODING = "UTF-8";
    private static final String ALGORITHM = "HmacSHA512";

    public static void main(String[] args) throws Exception {

        System.out.println("testing account balance:" +
                           (requestApi("GET", "/account/balance", null)?"PASS":"FAIL"));

        System.out.println("testing order history:" +
                           (requestApi("POST", "/order/history", "{\"currency\":\"AUD\", \"instrument\":\"BTC\",\"limit\":10}")?"PASS":"FAIL"));

        System.out.println("testing open order:" +
                           (requestApi("POST", "/order/open", "{\"currency\":\"AUD\", \"instrument\":\"BTC\",\"limit\":10}")?"PASS":"FAIL"));
    }

    public static boolean requestApi(String method, String path,  String postData){
        String response = "";
        try {
            //get the current timestamp. It's best to use ntp or similar services in order to sync your server time
            String timestamp = Long.toString(System.currentTimeMillis());

            // create the string that needs to be signed
            String stringToSign = buildStringToSign(path, null, postData, timestamp);
            System.out.println("str to sign:\n" + stringToSign + "\n");

            // build signature to be included in the http header
            String signature = signRequest(PRIVATE_KEY, stringToSign);

            //full url path
            String url = BASEURL + path;

            response = executeHttpRequest(method, postData, url, API_KEY, PRIVATE_KEY, signature, timestamp);
        } catch (Exception e) {
            System.out.println(e);
            return false;
        }
        System.out.println(response);
        return !response.contains("\"success\":false");
    }

    public static String executeHttpRequest(String method,  String postData, String url,
                                         String apiKey, String privateKey, String signature, String timestamp) throws Exception{
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpResponse httpResponse = null;

        try {
            HttpRequestBase httpReq = "POST".equalsIgnoreCase(method)?new HttpPost(url) : new HttpGet(url);

            // post any data that needs to go with http request.
            if (postData != null && httpReq instanceof HttpPost) {
                ((HttpPost)httpReq).setEntity(new StringEntity(postData, ENCODING));
            }
            // Set http headers

            httpReq.addHeader("Accept", "application/json");
            httpReq.addHeader("Accept-Charset", ENCODING);
            httpReq.addHeader("Content-Type", "application/json");

            // Add signature, timestamp and apiKey to the http header
            httpReq.addHeader(SIGNATURE_HEADER, signature);
            httpReq.addHeader(APIKEY_HEADER, apiKey);
            httpReq.addHeader(TIMESTAMP_HEADER, timestamp);

            // execute http request
            httpResponse = httpClient.execute(httpReq);

            if (httpResponse.getStatusLine().getStatusCode() != 200) {
                System.out.println("error response:" + httpResponse +"\n"
                                   +EntityUtils.toString(httpResponse.getEntity()));
                throw new RuntimeException(httpResponse.getStatusLine().getReasonPhrase());
            }
            // return JSON results as String
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String responseBody = responseHandler.handleResponse(httpResponse);
            return responseBody;

        }catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("unable to execute json call:" + e);
        } finally {
            // close http connection
            if (httpResponse != null) {
                HttpEntity entity = httpResponse.getEntity();
                if (entity != null) {
                    entity.consumeContent();
                }
            }
            if (httpClient != null) {
                httpClient.getConnectionManager().shutdown();
            }
        }
    }

    private static String buildStringToSign(String uri, String queryString,
                                            String postData, String timestamp) {
        // queryString must be sorted key=value& pairs
        String stringToSign = uri + "\n";
        if (queryString != null) {
            stringToSign += queryString + "\n";
        }
        stringToSign += timestamp + "\n";

        if (postData != null)
            stringToSign += postData;

        return stringToSign;
    }

    private static String signRequest(String secret, String data) {
        String signature = "";
        try {
            Mac mac = Mac.getInstance(ALGORITHM);
            SecretKeySpec secret_spec = new SecretKeySpec(Base64.decodeBase64(secret), ALGORITHM);
            mac.init(secret_spec);
            signature = Base64.encodeBase64String(mac.doFinal(data.getBytes()));
        } catch (InvalidKeyException e) {
            System.out.println(e);
        } catch (NoSuchAlgorithmException e) {
            System.out.println(e);
        } catch (Exception e) {
            System.out.println(e);
        }
        return signature;
    }
}

Error with open orders API

When requesting the /order/open endpoint, I get the following open orders :

{ success: true,
errorCode: null,
errorMessage: null,
orders:
[ { id: 113210644,
currency: 'AUD',
instrument: 'BTC',
orderSide: 'Ask',
ordertype: 'Limit',
creationTime: 1467603319137,
status: 'Placed',
errorMessage: null,
price: 90924000000,
volume: 69283199,
openVolume: 69283199,
clientRequestId: null,
trades: [] },
{ id: 113210676,
currency: 'AUD',
instrument: 'BTC',
orderSide: 'Ask',
ordertype: 'Limit',
creationTime: 1467603320074,
status: 'Placed',
errorMessage: null,
price: 91209000000,
volume: 473186621,
openVolume: 473186621,
clientRequestId: null,
trades: [] },
{ id: 113210545,
currency: 'AUD',
instrument: 'BTC',
orderSide: 'Ask',
ordertype: 'Limit',
creationTime: 1467603306793,
status: 'Placed',
errorMessage: null,
price: 92566000000,
volume: 349349684,
openVolume: 349349684,
clientRequestId: null,
trades: [] } ] }

However, there do not seem to be any open orders when I look at my open orders through the website.
Also, when I try to cancel them I get the following error :

{ success: true,
errorCode: null,
errorMessage: null,
responses:
[ { success: false,
errorCode: 3,
errorMessage: 'order is already cancelled.',
id: 113210676 } ] }

Can you please check why the open orders API is returning orders which seem to be closed ?

Skipping withdrawal confirmation email?

Hi, is there any way to skip the crypto withdrawal confirmation email? Short of implementing an email scraper to auto-click the approval requests, we'd have to otherwise manually approve.

Thank you for any advice :)

Orderbook - max ask and bids

path: /market/BTC/AUD/orderbook

Currently this returns the top 200 asks and bids.
It would be awesome if we could provide a parameter to specify how many (max) we want.
For one of my tasks I only care about the top 5, so if I can add max=5 to my request that would reduce the response payload significantly. Much more efficient for both you and us your users :)
Thanks!
Mark

Error codes

What are the undocumented error codes in this API?

A response like this:

{"success":false,"errorCode":5,"errorMessage":" error occured while trying to get balance."}

Is effectively useless when attempting to debug something.

Fund Transfer: withdrawCrypto, no withdraw tag?

I am looking to withdraw Ripple.
Is there any API request to be able to send to a specific address and tag?

Only address accessible with current request:
{"amount":10000000,"address":"1EJKj147QmEzywLnLpuxSr6SoPr1p62VBX","currency":"XRP"}

some wrong with API

When i take https://api.btcmarkets.net/market/ETH/BTC/orderbook from my browser (Chrome) i get
JSON responce {"currency":"BTC","instrument":"ETH","timestamp":1498230551,"asks":[[0.12356417,12.0],[0.12356418,0.00998372],[0.12356419,36.0],[0.12358,8.16],[0.124,2.88],[0.124531,0.34109796],[0.12580217,29.0],[0.135,0.05],[0.13899998,1.0],[0.139988,1.0],[0.144,1.98],[0.14458551,3.8373632],[0.146,0.99023059],[0.14875,0.29],[0.14999999,1.9],[0.15,2.25],[0.15200037,2.0],[0.161,0.29],[0.1999998,19.853103],[0.2,1.9510109],[0.2,2.0],[0.220664,30.89484],[0.25,0.78259708],[0.5,2.0],[0.55,20.0],[1.0,1.0]],"bids":[[0.11811116,4.275633],[0.11811115,4.275633],[0.11811115,37.0],[0.1181,0.00168004],[0.118,3.2132212],[0.117,0.05],[0.116,0.05],[0.115,0.05],[0.11463925,0.62445752],[0.114,0.05],[0.113,0.05],[0.1121,10.0],[0.112,0.05],[0.112,0.02],[0.1115,4.9179198],[0.111,0.05],[0.11,0.05],[0.11,1.0],[0.1091,14.596598],[0.109,0.2],[0.109,5.0],[0.105,1.0],[0.104,0.2],[0.1024,2.0],[0.1,7.0],[0.1,0.1],[0.1,0.1],[0.1,18.848196],[0.099,0.1],[0.09847644,1.647569],[0.098,0.05],[0.098,0.1],[0.098,15.0],[0.097,0.1],[0.096,0.1],[0.095,0.1],[0.095,1.0],[0.094,0.1],[0.093,0.1],[0.092,0.1],[0.091,0.1],[0.09,11.345877],[0.09,12.0],[0.089,0.1],[0.088,0.1],[0.087,0.1],[0.086,0.1],[0.086,4.0],[0.06122454,11.002101],[0.06,1.663008],[0.051,4.0],[0.05,5.0],[0.01,0.5],[4.3302E-4,0.5],[1.0E-8,7777.0]]}
When i try use custom library https://github.com/RyanCarrier/btcmarketsgo and use method GetOrderBook i get page with <p data-translate="why_captcha_detail">Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.</p>
I thought that the author has some mistake
And write code , and take the same error with CAPTCHA
That is not normal

/order/history endpoint not returning all orders.

The call to /order/history is not bringing back my most recent order (it's an AUD - Ethereum order if that makes a difference).
I can see on your website it is listed there in my account, but it is not there in the API response.

Your api seems to have something wrong with it every week! You guys need separate environments to work safely within rather than post to twitter about the live env being in an unreliable state all the time. I'm making assumptions here, but that's what it seems like is going on.

Authentication fails for /order/create, but not other resources

Hi, I'm trying to use the API via python for the first time. I'm using the resources from here: https://github.com/BTCMarkets/api-client-python

I am able to successfully perform API calls that require authentication (like checking my account balance, account trading fee, open orders). However, I get the authentication failure when i try to create an order.

When I try to create a very small order as a test, the order creation gets a failure response. Is there a minimum order size?

order create data: {"currency":"AUD","instrument":"ETH","price":37563920000.0,"volume":5255.491404396225,"orderSide":"Bid","ordertype":"Limit","clientRequestId":"removed"}

response data:
{u'errorCode': 1, u'errorMessage': u'Authentication failed.', u'success': False}

order history always empty - what unit is this since parameter?

Unless i specify 0 for since, I get no orders back using https://api.btcmarkets.net/order/trade/history. For example:

I have a ETH/BTC trade dated Thu Jul 27 14:54:48 BST 2017. So I make a request for trades since Mon May 01 01:00:00 BST 2017 converted to unix time:

{"currency":"BTC","instrument":"ETH","limit":200,"since":1493596800}

But nothing comes back.

If I change to a zero time:

{"currency":"BTC","instrument":"ETH","limit":200,"since":0}

Then it returns trade data.

https://github.com/BTCMarkets/API/wiki/Trading-API#order-history

Query available currencies question.

As explained here you can run a get request for market data by using /market/BTC/AUD/tick.

Is there a way to query market for the available paths instead of manually putting each path into the code?
For example, if you add support for an additional coin/currency I would like to be able to query this from the API level.

Sorry if I'm missing something here as I very new to interacting with APIs.

Order history is not working

I get the following error when I try to request the /order/history endpoint :

{"success":false,"errorCode":5,"errorMessage":"order history is currently unavailable"}

This has been the case for nearly two weeks now. Any idea when this will be back working ?

"limit" parameter ignored in /order/open request

/order/open: {"currency":"AUD","instrument":"XRP","limit":1,"since":0}
returns ALL the open orders for AUD/XRP rather than just 1.

/order/history: {"currency":"AUD","instrument":"XRP","limit":1,"since":0}
returns 1 order, as specified.

/order/open: {"currency":"AUD","instrument":"LTC","limit":1,"since":0}
returns ALL the open orders for AUD/LTC rather than just 1.

Apologies if I'm missing something obvious.

no trade side on MarketTrade websocket event

Hi , there is no information regarding trade side(buy or sell) on MarketTrade event. Are there any workaround ? I see that on the website on "Last 50 Trades" box the trades have different colors .

What are the causes of 'Price is outside of market range'?

I'm seeing this error 'Price is outside of market range' for the following order creation data:
{"currency":"AUD","instrument":"ETH","price":32115000000,"volume":3087568,"orderSide":"Bid","ordertype":"Limit","clientRequestId":"x"}

funding history?

Is there an API call that will return a history of deposits and withdrawals?

PHP Cant Authenticate

I need some help please. Getting constant Authentication Failed message.

<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

date_default_timezone_set('Australia/Sydney');

echo 'Date: ' . date("D M d, Y G:i a") . '<br>';

$secret_key = "the_secret_from_website=Private-(secret)-API-Key";
$secret_key_encoded = base64_encode($secret_key);

$public_key = "the_public_from_website=Public-API-Key";

$milliseconds = round(microtime(true) * 1000);

$msg = '/account/balance' . '\n' . $milliseconds . '\n';
echo "Message is: " . $msg . "<br>";

$encodedMsg =   hash_hmac('sha512', $msg, $secret_key_encoded); 
echo "Encoded Message is: " . $encodedMsg . "<br>";

// Create a stream
$opts = array(
  'http'=>array(
    	'method'=>"GET",
    	'header'=>	"Accept: application/json\r\n" .
			"Accept-Charset: UTF-8\r\n" .
			"Content-Type: type=application/json\r\n" .
			"apikey: " . $public_key . "\r\n" .
			"timestamp: " . $milliseconds . "\r\n" .
			"User-Agent: btc markets php client\r\n" .
			"signature: " . $encodedMsg . "\r\n"
  )
);

$context = stream_context_create($opts);

var_dump($opts);

// Open the file using the HTTP headers set above
$json = file_get_contents('https://api.btcmarkets.net/account/balance', false, $context);

var_dump($json);

// $array = json_decode($json, true);
// echo "File is: " + $array;

?>

Any advice please?

Serious issue: Unable to cancel order with the API

Some of the cancel order requests that I issue seem to get stuck somewhere, and I get the following error :

errorCode: 3,
errorMessage: 'order cancellation is in progress.'

Once this issue appears it is impossible to cancel the order, even by issuing later cancel requests. The order stays open forever without possibility to cancel it via the API.

I have contacted support but they do not seem to be able to solve the issue.

Account API - No decimal places

Hi,
Maybe I'm missing something but all balance values returned do not have decimal places.
This is the format:
{"balance":1000000000,"pendingFunds":0,"currency":"AUD"}
My current balance in AU that is returned is: 245745420414.
This amount is actually $2457.45, as displayed when I login to the site. But what if the amount was $245745.42, how do I programatically determine the correct balance when there are no decimal places?

Same with all currencies, e.g. BTC, I get back 45038674 as balance, which is 0.45038674 but how do I know it is not 45.038674?
Is this a bug and balances should be returned with decimal places, or is there some formula I need to apply to accurately determine my balances via the API?

Thanks!
Mark

Market Data - Tick Volumes

path: /market/BTC/AUD/tick
returns: {"bestBid":844.0,"bestAsk":844.98,"lastPrice":845.0,"currency":"AUD","instrument":"BTC","timestamp":1476242958,"volume24h":172.60804}
It would be awesome if this also returned, bestBidVolume and bestAskVolume.
Any chance of having these added? For one of my tasks it would reduce the number of times I need to call orderbook if they were there :)
Thanks!
Mark

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.