API Documentation

Getbtc REST API Documentation

Welcome to the Getbtc REST API documentation. This API (Application Programming Interface) will allow you to access the functionality of this exchange by means of HTTP requests, making integration with your own applications possible.

Connecting to the API

You can access the API at the following url:

https://getbtc.org/api/

You are permited to make up to 60 requests a minute.

Usage

In order to use a public API method, you must make an HTTP request to the appropriate endpoint for that particular method, sending the appropriate GET or POST parameters for that method. You can also send them in the PAYLOAD of the request in JSON format.

To access protected API methods, you must obtain an API key/secret pair. Their usage is explained further ahead in this document.

Here are a few basic usage examples:

# Example request using CURL on the command line
curl "https://getbtc.org/api/transactions" \
-d currency="EUR" \
-d limit=5	
// Example valid response
{"transactions": {
	"0":{"id":"131","date":"2014-11-13 10:42:46","btc":"1.00000000","maker_type":"buy","price":"10.00","amount":"10.00","currency":"USD"},
	"1":{"id":"129","date":"2014-11-11 11:14:12","btc":"0.50000000","maker_type":"buy","price":"11.27","amount":"5.63","currency":"EUR"},
	"2":{"id":"128","date":"2014-11-11 11:13:49","btc":"0.50000000","maker_type":"buy","price":"10.91","amount":"5.46","currency":"USD"},
	"3":{"id":"127","date":"2014-11-10 18:29:15","btc":"0.50000000","maker_type":"buy","price":"11.20","amount":"5.60","currency":"USD"},
	"4":{"id":"126","date":"2014-11-10 18:25:21","btc":"0.50000000","maker_type":"buy","price":"11.20","amount":"5.60","currency":"USD"},
	"request_currency":"USD"
	}
}
// Example error response
{"errors":[{"message":"Invalid currency.","code":"INVALID_CURRENCY"}]}

 

Public API Methods

These methods can be accessed without an account or API key.

Stats

Returns statistics about the current state of the exchange.

GET https://getbtc.org/api/stats

Parameters:

Response:

Historical Prices

Gives daily market close prices for the selected period.

GET https://getbtc.org/api/historical-prices

Parameters:

Response:

Order Book

Returns information on all the orders currently in the order book. Return will be grouped into two different arrays for bid and ask respectively.

GET https://getbtc.org/api/order-book

Parameters:

Response:

Transactions

Get the latest transactions that ocurred in the exchange, ordered by date in descending order.

GET https://getbtc.org/api/transactions

Parameters:

Response:

 

Protected API Methods

In order to access these methods, you must obtain an API key/secret pair to authenticate your request.

Obtaining An API Key

To get access to our API, you must generate an API key on the API Access page. You must have two-factor authentication enabled on your account to be able to view this page. Upon generating a new API key, you will be given an API secret code. This value will only be shown to you once. Please store it in a secure place, as you will need it to use it together with your API key.

Once you have generated an API key, you can allow or restrict it's holder's access to the parent account's functionality by checking or unchecking the checkboxes in the "permissions" line under the API key.

Authenticating Your Request

To authenticate a request with your API key/secret pair, you must include the following parameters in your POST parameters or the JSON PAYLOAD of your request:

We know that generating a signature might be a bit intimidating if you're doing it for the first time, so please see the following examples:

// Javascript Example
	
// Uses http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/hmac-sha256.js
// ...and http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/enc-base64-min.js

// we add our public key and nonce to whatever parameters we are sending
var params = {};
params.currency = "eur";
params.price = 200;
params.api_key = api_key;
params.nonce = Math.round(new Date().getTime() / 1000);
	
// create the signature
var hash = CryptoJS.HmacSHA256(JSON.stringify(data), api_secret);
var hashInBase64 = CryptoJS.enc.Hex.stringify(hash);
	
// add signature to request parameters
params.signature = hashInBase64;
// PHP Example
	
// we add our public key and nonce to whatever parameters we are sending
$commands['side'] = 'sell';
$commands['type'] = 'stop';
$commands['api_key'] = $api_key;
$commands['nonce'] = time();
	
// create the signature
$signature = hash_hmac('sha256', json_encode($commands), $api_secret);
	
// add signature to request parameters
$commands['signature'] = $signature;
# Python Example
	
import hashlib
import hmac
	
// we add our public key and nonce to whatever parameters we are sending
params = {'currency': 'eur', 'price': 200, 'api_key': api_key, 'nonce': time.time()}

// create the signature
message = bytes(json.dumps(params)).encode('utf-8')
secret = bytes(api_secret).encode('utf-8')
signature = hmac.new(secret, message, digestmod=hashlib.sha256).hexdigest()
	
// add signature to request parameters	
params['signature'] = signature	
// C# Example
	
using System.Security.Cryptography;

// we add our public key and nonce to whatever parameters we are sending
var params1 = new List>();
params1.Add(new KeyValuePair("api_key", api_key));
params1.Add(new KeyValuePair("nonce", (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds));
	
// create the signature
JavaScriptSerializer serializer = new JavaScriptSerializer();
var message = serializer.Serialize(params1);
	
secret = secret ?? "";
var encoding = new System.Text.ASCIIEncoding();
byte[] keyByte = encoding.GetBytes(secret);
byte[] messageBytes = encoding.GetBytes(message);
using (var hmacsha256 = new HMACSHA256(keyByte))
{
	byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
	var signature = BitConverter.ToString(hashmessage);
	signature = signature.Replace("-", "");
	
	// add signature to request parameters
	params1.Add(new KeyValuePair("signature", signature));
}
/* Java Example */
	
/* Dependent on Apache Commons Codec to encode in base64. */
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Hex;

/* we add our public key and nonce to whatever parameters we are sending */
Map params = new HashMap();
params.put("api_key", "demo");
params.put("nonce", ((int) (System.currentTimeMillis() / 1000L)));
	
/* create the signature */
String secret = "secret";
String message = new JSONObject(params).toString();

Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
sha256_HMAC.init(secret_key);

String hash = Hex.encodeHexString(sha256_HMAC.doFinal(message.getBytes()));

/* add signature to request parameters */
params.put("signature", hash);

Balances and Info

Obtain the account's balances and fee levels.

POST https://getbtc.org/api/balances-and-info

Response:

Open Orders

Get the account's current open orders, grouped by order side (bid or ask).

POST https://getbtc.org/api/open-orders

Parameters:

Response:

User Transactions

Get a list of the account's transactions, ordered by date, in descending order.

POST https://getbtc.org/api/user-transactions

Parameters:

Response:

Existing Bitcoin Deposit Addresses

Get a list of the account's existing addresses for receiving Bitcoin.

POST https://getbtc.org/api/btc-deposit-address/get

Parameters:

Response:

Get New Bitcoin Deposit Addresses

Get a new Bitcoin deposit address for the account.

POST https://getbtc.org/api/btc-deposit-address/new

Response:

Get Deposits

Get a list of deposits (BTC or fiat) made to the account, ordered by date, in descending order.

POST https://getbtc.org/api/deposits/get

Parameters:

Response:

Get Withdrawals

Get a list of withdrawals (BTC or fiat) from the account, ordered by date, in descending order.

POST https://getbtc.org/api/withdrawals/get

Parameters:

Response:

Place One (or Many) New Orders

Place one or many new orders from your account. To place multiple orders, you can send a multidimensional array called orders, which should contain all the parameters in each array element as specified below.

POST https://getbtc.org/api/orders/new

Parameters:

Response:

Edit One (or Many) Orders

Edit one or many of the orders that you have placed. To edit multiple orders, you can send a multidimensional array called orders, which should contain all the parameters in each array element as specified below.

POST https://getbtc.org/api/orders/edit

Parameters:

Response:

Cancel One, Many or ALL Orders

Cancel one or many active orders. To cancel multiple orders, you can send a multidimensional array called orders, which should contain all the parameters in each array element as specified below. To cancel ALL orders, simply send a parameter called all - there is no need to send anything else.

POST https://getbtc.org/api/orders/cancel

Parameters:

Response:

Status of One (or Many) Orders

Obtain the current state of one or many of the orders that have been placed by the account. To get multiple orders, you can send a multidimensional array called orders, which should contain all the parameters in each array element as specified below.

POST https://getbtc.org/api/orders/status

Parameters:

Response:

Make a Withdrawal

To make a withdrawal from your account to an existing Bitcoin address or fiat bank account. Please note, you must link the desired bank account number to your account in the bank accounts page in order for this feature to work. Otherwise, your withdrawals will fail.

POST https://getbtc.org/api/withdrawals/new

Parameters:

Response:

Make a Withdrawal GetBtc Code

POST https://getbtc.org/api/code/get

Parameters:

Response:

Make a Deposit GetBtc Code

POST https://getbtc.org/api/code/set

Parameters:

Response: