Cobinhood Client API
Refer Cobinhood Public API https://cobinhood.github.io/api-public
Composer Command
composer create-project dalvin1991/cobinhood_client_api
Client $client = new CobinhoodClientAPI("API-KEY");
$client->getTime();
$client->getInfo();
$client->getCurrencies();
$client->getTradingPairs();
$client->getOrderBooks($tradingPairID,$limit);
$tradingPairID (string) : you may use the value return by Get Trading Pairs
$limit (int) : number of records return (Optional parameter)
$client->getStats();
$client->getTickers($tradingPairID);
$tradingPairID (string) : you may use the value return by Get Trading Pairs
$client->getRecentTrades($tradingPairID,$limit);
$tradingPairID (string) : you may use the value return by Get Trading Pairs
$limit (int) : number of records return (Optional parameter)
$client->getCandles($tradingPairID,$timeframe,$startTime,$endTime);
$tradingPairID (string) : you may use the value return by Get Trading Pairs
$timeframe (string) : candles timeframe ("1m", "5m", "15m", "30m", "1h", "3h", "6h", "12h", "1D", "7D", "14D", "1M")
$startTime (int) : the unix timestamp for the first of candles (Optional parameter)
$endTime (int) : the unix timestamp for the last of candles (Optional parameter)
$client->getOrder($orderID);
$orderID (string) : order id for the order
$client->getOrderTrades($orderID);
$orderID (string) : order id for the order
$client->getOrders($tradingPairID,$limit);
$tradingPairID (string) : you may use the value return by Get Trading Pairs (Optional parameter)
$limit (int) : number of records return (Optional parameter)
$client->placeOrder($tradingPairID, $side, $type, $price, $size);
$tradingPairID (string) : you may use the value return by Get Trading Pairs
$side (string) : the order side ("bid", "ask")
$type (string) : the order type ("market", "limit", "stop", "stop_limit")
$price (string) : price for the order
$size (string) : size for the order
$client->modifyOrder($orderID,$price,$size);
$orderID (string) : order id for the order
$price (string) : price for the order
$size (string) : size for the order
$client->cancelOrder($orderID);
$orderID (string) : order id for the order
$client->getOrderHistory($tradingPairID, $limit);
$tradingPairID (string) : you may use the value return by Get Trading Pairs (Optional parameter)
$limit (int) : number of records return (Optional parameter)
$client->getTrade($tradeID);
$tradeID (string) : trade id for the trade
$client->getTrades($tradingPairID, $limit);
$tradingPairID (string) : you may use the value return by Get Trading Pairs (Optional parameter)
$limit (int) : number of records return (Optional parameter)
$client->getLedger($currency,$limit);
$currency (string) : you may use the value return by Get Currencies (Optional parameter)
$limit (int) : number of records return (Optional parameter)
$client->getDepositAddresses($currency);
$currency (string) : you may use the value return by Get Currencies (Optional parameter)
$client->getWithdrawalAddresses($currency);
$currency (string) : you may use the value return by Get Currencies (Optional parameter)
$client->getWithdrawal($withdrawalID);
$withdrawalID (string) : withdrawal ID
$client->getWithdrawals();
$client->getDeposit($depositID);
$depositID (string) : depositID ID
$client->getDeposits();
In websocket, I have implemented the ping message to be sent every 5 sec to maintain the socket stay open after each socket function has called.
You may refer my index.php example, for each websocket function you may put in your callback function, when receive any message. $class will be your class, then $functionName is the class function name to be call.
$client->startOrderWS($keepAlive,$timeout,$class,$functionName);
$keepAlive (bool) : keep the socket alive until the timeout (Optional parameter)
$timeout (int) : the socket timeout time with seconds (Optional parameter)
$class (class) : the callback Class (Optional parameter)
$functionName (string) : the callback Class's function (Optional parameter)
$client->startTradesWS($tradingPairID,$keepAlive,$timeout,$class,$functionName);
$tradingPairID (string or array) : it can be string for single trading pair or array for multiple trading pair subscribe
$keepAlive (bool) : keep the socket alive until the timeout (Optional parameter)
$timeout (int) : the socket timeout time with seconds (Optional parameter)
$class (class) : the callback Class (Optional parameter)
$functionName (string) : the callback Class's function (Optional parameter)
$client->startOrderBookWS($tradingPairsForOrderBookWS,$keepAlive,$timeout,$class,$functionName);
$tradingPairsForOrderBookWS (array) : you may refer the structure like this
$tradingPairsForOrderBookWS=[
["tradingPairID"=>"BAT-BTC","precision"=>"1E-8"],
["tradingPairID"=>"COB-BTC","precision"=>"1E-8"],
["tradingPairID"=>"ETH-BTC","precision"=>"1E-8"]
];
$keepAlive (bool) : keep the socket alive until the timeout (Optional parameter)
$timeout (int) : the socket timeout time with seconds (Optional parameter)
$class (class) : the callback Class (Optional parameter)
$functionName (string) : the callback Class's function (Optional parameter)
$client->startTinkerWS($tradingPairID,$keepAlive,$timeout,$class,$functionName);
$tradingPairID (string or array) : it can be string for single trading pair or array for multiple trading pair subscribe
$keepAlive (bool) : keep the socket alive until the timeout (Optional parameter)
$timeout (int) : the socket timeout time with seconds (Optional parameter)
$class (class) : the callback Class (Optional parameter)
$functionName (string) : the callback Class's function (Optional parameter)
$client->startCandlesWS($tradingPairsForCandlesWS,$keepAlive,$timeout,$class,$functionName);
$tradingPairsForOrderBookWS (array) : you may refer the structure like this
$tradingPairsForCandlesWS=[
["tradingPairID"=>"BAT-BTC","timeframe"=>"30m"],
["tradingPairID"=>"COB-BTC","timeframe"=>"30m"],
["tradingPairID"=>"ETH-BTC","timeframe"=>"30m"]
];
$keepAlive (bool) : keep the socket alive until the timeout (Optional parameter)
$timeout (int) : the socket timeout time with seconds (Optional parameter)
$class (class) : the callback Class (Optional parameter)
$functionName (string) : the callback Class's function (Optional parameter)