Public API



Common params
# Name Description
1 time UTC Time in seconds. Difference up to +-60 seconds with server's time is allowed.
2 hash MD5 signature for the request, including time.


Order Books



URL
GET https://btcbear.com/?p=public-api&action=book
Args
# name Description
1 symbols The pair of currencies to use.
Values : ['BTC/USD', 'BTC/EUR', 'LTC/USD', 'LTC/EUR', 'LTC/BTC']
{
    "status": "success",
    "request": {
        "hash": "cfcd208495d565ef66e7dff9f98764da"
    },
    "response": {
        "symbols": "BTC\/USD",
        "book_buy": [
            {
                "id": 174,
                "type": "buy",
                "amount": "0.01000000",
                "rate": "190.00000000"
            },
            {
                "id": 176,
                "type": "buy",
                "amount": "0.01000000",
                "rate": "170.00000000"
            }
        ],
        "book_sell": [
            {
                "id": 178,
                "type": "sell",
                "amount": "0.03000000",
                "rate": "210.00000000"
            }
        ]
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=public-api";
$action = "book";
$time = time();
$symbols = "BTC/USD";

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"symbols" => $symbols
));

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&symbols=".$symbols;
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args) {
	ksort($args); // sort args by keys
	$string = '';
		
	foreach ($args as $key => $value) {
		$string .= $key.'-'.$value.'|';
	}
	
	return hash('md5', $string);
}
														
													


Market Infos



URL
GET https://btcbear.com/?p=public-api&action=market
Args
# name Description
1 symbols The pair of currencies to use.
Values : ['BTC/USD', 'BTC/EUR', 'LTC/USD', 'LTC/EUR', 'LTC/BTC']
{
    "status": "success",
    "request": {
        "hash": "cfcd208495d565ef66e7dff9f98764da"
    },
    "response": {
        "symbols": "BTC\/USD",
        "low": "190.00000000",
        "high": "210.00000000",
        "last": "200.00000000"
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=public-api";
$action = "market";
$time = time();
$symbols = "BTC/USD";

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"symbols" => $symbols
));

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&symbols=".$symbols;
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string .= $key.'-'.$value.'|';
	}
	
	return hash('md5', $string);
}
														
													


Private API



Introduction
This part of API allows you to manage your account.
You must enable API in your settings and get your Public and Private keys.
Common params
# Name Description
1 public_key Your public key available in settings area
2 time UTC Time in seconds. Difference up to +-60 seconds with server's time is allowed.
3 hash MD5 signature for the request, generated with your private key.


Balances



URL
GET https://btcbear.com/?p=private-api&action=balances
Permission
Account Info : Read (perm_account_info_read)
{
    "status": "success",
    "request": {
        "hash": "cfcd208495d565ef66e7dff9f98764da"
    },
    "response": {
        "USD": "50.17145098",
        "EUR": "94.99800000",
        "BTC": "0.84973260",
        "LTC": "20.00000000"
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=private-api";
$public_key = ""; // change it
$private_key = ""; // change it
$action = "balances";
$time = time();

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"public_key" => $public_key
), $private_key);

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&public_key=".$public_key;
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args, $private_key) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string += $key.'-'.$value.'|';
	}
	
	$string .= 'key-'.$private_key;
	
	return hash('md5', $string);
}
														
													


Simulate Market Order



URL
GET https://btcbear.com/?p=private-api&action=simulate-market
Permission
Orders : Read (perm_account_orders_read)
Args
# name Description
1 type Set the type of trade to simulate
Values : ['buy', 'sell']
2 symbols The pair of currencies to use.
Values : ['BTC/USD', 'BTC/EUR', 'LTC/USD', 'LTC/EUR', 'LTC/BTC']
3 amount The amount to buy / sell.
Units : ['BTC', 'LTC']
{
    "status": "success",
    "request": {
        "hash": "cfcd208495d565ef66e7dff9f98764da"
    },
    "response": {
        "symbols": "buy",
        "symbols": "BTC\/USD",
        "price": "2.10000000"
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=private-api";
$public_key = ""; // change it
$private_key = ""; // change it
$time = time();
$action = "simulate-market";
$type = "buy";
$symbols = "BTC/USD";
$amount = "0.01";

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"public_key" => $public_key,
	"symbols" => $symbols,
	"type" => $type,
	"amount" => $amount
), $private_key);

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&public_key=".$public_key;
$request .= "&type=".$type;
$request .= "&symbols=".$symbols;
$request .= "&amount=".$amount; 
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args, $private_key) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string += $key.'-'.$value.'|';
	}
	
	$string .= 'key-'.$private_key;
	
	return hash('md5', $string);
}
														
													


Execute Market Order



URL
GET https://btcbear.com/?p=private-api&action=market-order
Permission
Orders : Write (perm_account_orders_write)
Args
# name Description
1 type Set the type of trade to execture
Values : ['buy', 'sell']
2 symbols The pair of currencies to use.
Values : ['BTC/USD', 'BTC/EUR', 'LTC/USD', 'LTC/EUR', 'LTC/BTC']
3 amount The amount to buy / sell.
Units : ['BTC', 'LTC']
{
    "status": "success",
    "request": {
        "hash": "cfcd208495d565ef66e7dff9f98764da"
    },
    "response": {
        "type": "buy",
        "symbols": "BTC\/USD"
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=private-api";
$public_key = ""; // change it
$private_key = ""; // change it
$time = time();
$action = "market-order";
$type = "buy";
$symbols = "BTC/USD";
$amount = "0.01";

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"public_key" => $public_key,
	"symbols" => $symbols,
	"type" => $type,
	"amount" => $amount
), $private_key);

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&public_key=".$public_key;
$request .= "&type=".$type;
$request .= "&symbols=".$symbols;
$request .= "&amount=".$amount; 
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args, $private_key) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string += $key.'-'.$value.'|';
	}
	
	$string .= 'key-'.$private_key;
	
	return hash('md5', $string);
}
														
													


Execute Limit Order



URL
GET https://btcbear.com/?p=private-api&action=limit-order
Permission
Orders : Write (perm_account_orders_write)
Args
# name Description
1 type Set the type of trade to execture
Values : ['buy', 'sell']
2 symbols The pair of currencies to use.
Values : ['BTC/USD', 'BTC/EUR', 'LTC/USD', 'LTC/EUR', 'LTC/BTC']
3 amount The amount to buy / sell.
Units : ['BTC', 'LTC']
4 limit The limit price to buy / sell.
Units : ['USD', 'EUR', 'BTC' (only for 'LTC/BTC')]
{
    "status": "success",
    "request": {
        "hash": "cfcd208495d565ef66e7dff9f98764da"
    },
    "response": {
        "type": "buy",
        "amount": "0.01000000 BTC",
        "rate": "190.00000000"
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=private-api";
$public_key = ""; // change it
$private_key = ""; // change it
$time = time();
$action = "limit-order";
$type = "buy";
$symbols = "BTC/USD";
$amount = "0.01";
$limit = "190";

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"public_key" => $public_key,
	"symbols" => $symbols,
	"type" => $type,
	"amount" => $amount,
	"limit" => $limit
), $private_key);

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&public_key=".$public_key;
$request .= "&type=".$type;
$request .= "&symbols=".$symbols;
$request .= "&amount=".$amount; 
$request .= "&limit=".$limit; 
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);
echo $response;

// parse JSON from $response
$json = json_decode($response);



function genHash($args, $private_key) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string += $key.'-'.$value.'|';
	}
	
	$string .= 'key-'.$private_key;
	
	return hash('md5', $string);
}
														
													


Get Active Orders



URL
GET https://btcbear.com/?p=public-api&action=active-orders
Permission
Orders : Read (perm_account_orders_read)
Args
# name Description
1 symbols The pair of currencies to use.
Values : ['BTC/USD', 'BTC/EUR', 'LTC/USD', 'LTC/EUR', 'LTC/BTC']
{
    "status": "success",
    "request": {
        "hash": "c86e533bdda23312ace98689a988b89c"
    },
    "response": {
        "size": 1,
        "book": [
            {
                "id": 378,
                "pair": "BTC\/USD",
                "type": "sell",
                "username": "admin",
                "amount": "0.01000000",
                "rate": "205.00000000",
                "fees": "0.00001000",
                "date": "2015-11-23 14:54:19"
            }
        ]
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=private-api";
$public_key = ""; // change it
$private_key = ""; // change it
$action = "active-orders";
$time = time();
$symbols = "BTC/USD";

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"public_key" => $public_key,
	"symbols" => $symbols
), $private_key);

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&public_key=".$public_key;
$request .= "&symbols=".$symbols;
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args, $private_key) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string .= $key.'-'.$value.'|';
	}
	
	$string .= 'key-'.$private_key;
	
	return hash('md5', $string);
}
														
													


Deposit BTCBear ecode



URL
GET https://btcbear.com/?p=private-api&action=redeem-deposit
Permission
Deposit BTCBear ecode : Write (perm_account_redeem_deposit_write)
Args
# name Description
1 redeem BTCBear ecode to deposit
Values : ['0a7Gx-F0xQN-Z3s8t-TT5vu', '0a7GxF0xQNZ3s8tTT5vu', ...]
{
    "status": "success",
    "request": {
        "hash": "067ee6df6946da791c0cddc7e131dd6a"
    },
    "response": {
        "currency": "USD",
        "amount": "1.0000000000"
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=private-api";
$public_key = ""; // change it
$private_key = ""; // change it
$action = "redeem-deposit";
$time = time();
$redeem = "0a7Gx-F0xQN-Z3s8t-TT5vu";

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"public_key" => $public_key,
	"redeem" => $redeem
), $private_key);

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&public_key=".$public_key;
$request .= "&redeem=".$redeem;
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args, $private_key) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string .= $key.'-'.$value.'|';
	}
	
	$string .= 'key-'.$private_key;
	
	return hash('md5', $string);
}
														
													


Deposit ecode History



URL
GET https://btcbear.com/?p=private-api&action=redeem-deposit-history
Permission
Deposit BTCBear ecode : Read (perm_account_redeem_deposit_read)
{
    "status": "success",
    "request": {
        "hash": "74e6e23390b0ac39e51ac2a1edd1bb80"
    },
    "response": {
        "size": 1,
        "ecodes": [
            {
                "id": 5,
                "date_create": "2016-01-02 20:12:06",
                "date_use": "2016-01-02 20:12:29",
                "owner": "admin",
                "user": "admin",
                "currency": "USD",
                "amount": "1.0000000000",
                "code": "0a7GxF0xQNZ3s8tTT5vu",
                "used": 1
            }
        ]
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=private-api";
$public_key = ""; // change it
$private_key = ""; // change it
$action = "redeem-deposit-history";
$time = time();

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"public_key" => $public_key
), $private_key);

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&public_key=".$public_key;
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args, $private_key) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string .= $key.'-'.$value.'|';
	}
	
	$string .= 'key-'.$private_key;
	
	return hash('md5', $string);
}
														
													


Generate BTCBear ecode



URL
GET https://btcbear.com/?p=private-api&action=redeem-generate
Permission
Withdraw BTCBear ecode : Write (perm_account_redeem_withdraw_write)
Args
# name Description
1 currency Currency of the redeem code
Values : ['USD', 'EUR']
2 amount Amount of the redeem code
{
    "status": "success",
    "request": {
        "hash": "a3b03a3d4c6ae6ea226d048d5af764b4"
    },
    "response": {
        "currency": "USD",
        "amount": "1.05",
        "ecode": "VRbKN-kF7N0-ChDJ8-qt7Wv"
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=private-api";
$public_key = ""; // change it
$private_key = ""; // change it
$action = "redeem-generate";
$time = time();
$currency = "USD";
$amount = 1.05;

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"public_key" => $public_key,
	"currency" => $currency,
	"amount" => $amount
), $private_key);

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&public_key=".$public_key;
$request .= "¤cy=".$currency;
$request .= "&amount=".$amount;
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args, $private_key) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string .= $key.'-'.$value.'|';
	}
	
	$string .= 'key-'.$private_key;
	
	return hash('md5', $string);
}
														
													


Generated ecode History



URL
GET https://btcbear.com/?p=private-api&action=redeem-withdraw-history
Permission
Withdraw BTCBear ecode : Read (perm_account_redeem_withdraw_read)
{
    "status": "success",
    "request": {
        "hash": "19f1a8f7883a69a02a18c28312d7d7be"
    },
    "response": {
        "size": 1,
        "ecodes": [
            {
                "id": 8,
                "date_create": "2016-01-03 10:13:38",
                "date_use": "0000-00-00 00:00:00",
                "owner": "admin",
                "user": "",
                "currency": "USD",
                "amount": "1.0500000000",
                "code": "VRbKNkF7N0ChDJ8qt7Wv",
                "used": 0
            }
        ]
    }
}
													
														
// basic setup vars
$base = "https://btcbear.com/?p=private-api";
$public_key = ""; // change it
$private_key = ""; // change it
$action = "redeem-withdraw-history";
$time = time();

// generate hash
$hash = genHash(array(
	"action" => $action,
	"time" => $time,
	"public_key" => $public_key
), $private_key);

// generate URL
$request = $base;
$request .= "&action=".$action;
$request .= "&time=".$time;
$request .= "&public_key=".$public_key;
$request .= "&hash=".$hash;

// request URL
$response = file_get_contents($request);

// parse JSON from $response
$json = json_decode($response);



function genHash($args, $private_key) {
	ksort($args); // sort args by keys
	
	$string = '';
		
	foreach ($args as $key => $value) {
		$string .= $key.'-'.$value.'|';
	}
	
	$string .= 'key-'.$private_key;
	
	return hash('md5', $string);
}