1. Go to this page and download the library: Download buzorin/php-cobinhood-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
buzorin / php-cobinhood-api example snippets
$cobinhood = new Cobinhood\API_client("<api key>");
$cobinhood = new Cobinhood\API_client("<api key>");
$limit = 5; // Optional. Defaults to 50 if not specified, if limit is 0, it means to fetch the whole order book.
$depth = $cobinhood->get_order_book("COB-BTC", $limit);
if (!$depth["error"]) {
print_r($depth);
}
$currencies = $cobinhood->get_currencies();
if (!$currencies["error"]) {
print_r($currencies);
}
$trading_pairs = $cobinhood->get_trading_pairs();
if (!$trading_pairs["error"]) {
print_r($trading_pairs);
}
$stats = $cobinhood->get_stats();
if (!$stats["error"]) {
print_r($stats);
}
$ticker = $cobinhood->get_ticker("COB-BTC");
if (!$ticker["error"]) {
print_r($ticker);
}
$tickers = $cobinhood->get_tickers();
if (!$tickers["error"]) {
print_r($tickers);
}
$limit = 3; // Optional. Defaults to 20 if not specified, max 50.
$trades = $cobinhood->get_trades("COB-BTC", $limit);
if (!$trades["error"]) {
print_r($trades);
}
$timeframe = "5m"; // Timeframes: 1m, 5m, 15m, 30m, 1h, 3h, 6h, 12h, 1D, 7D, 14D, 1M
$startTime = 1519307723000; // Optional. Unix timestamp in milliseconds. Defaults to 0 if not specified. You can set it to false.
$endTime = 1519308723000; // Optional. Unix timestamp in milliseconds. Defaults to current server time if not specified. You can set it to false.
$candles = $cobinhood->get_candles("COB-BTC", $timeframe, $endTime, $startTime);
if (!$candles["error"]) {
print_r($candles);
}
$limit = 2; // Optional. Defaults to 20 if not specified, max 50.
$open_orders = $cobinhood->get_open_orders("COB-ETH", $limit);
if (!$open_orders["error"]) {
print_r($open_orders);
}
$limit = 2; // Optional. Defaults to 20 if not specified, max 50.
$open_orders_all = $cobinhood->get_open_orders_all($limit);
if (!$open_orders_all["error"]) {
print_r($open_orders_all);
}
$limit = 2; // Optional. Defaults to 50 if not specified.
$orders_history = $cobinhood->get_orders_history("COB-BTC", $limit);
if (!$orders_history["error"]) {
print_r($orders_history);
}
$limit = 2; // Optional. Defaults to 50 if not specified.
$orders_history_all = $cobinhood->get_orders_history_all($limit);
if (!$orders_history_all["error"]) {
print_r($orders_history_all);
}
$balances = $cobinhood->get_balances();
if (!$balances["error"]) {
print_r($balances);
}
$limit = 3; // Defaults to 20 if not specified, max 50.
$balance_history = $cobinhood->get_balance_history("ETH", $limit);
if (!$balance_history["error"]) {
print_r($balance_history);
}
$limit = 3; // Defaults to 20 if not specified, max 50.
$balance_history_all = $cobinhood->get_balance_history_all($limit);
if (!$balance_history_all["error"]) {
print_r($balance_history_all);
}
$deposit_addresses = $cobinhood->get_deposit_addresses("ETH");
if (!$deposit_addresses["error"]) {
print_r($deposit_addresses);
}
$deposit_addresses_all = $cobinhood->get_deposit_addresses_all();
if (!$deposit_addresses_all["error"]) {
print_r($deposit_addresses_all);
}