PHP code example of linwj / crex24
1. Go to this page and download the library: Download linwj/crex24 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/ */
linwj / crex24 example snippets
$crex=new Crex();
//You can set special needs
$crex->setOptions([
//Set the request timeout to 60 seconds by default
'timeout'=>10,
//If you are developing locally and need an agent, you can set this
'proxy'=>true,
//More flexible Settings
/* 'proxy'=>[
'http' => 'http://127.0.0.1:12333',
'https' => 'http://127.0.0.1:12333',
'no' => ['.cn']
], */
//Close the certificate
//'verify'=>false,
]);
$crex=new Crex();
try {
$result=$crex->market()->getCurrencies();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->market()->getInstruments();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->market()->getTickers();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->market()->getRecentTrades([
'instrument'=>'LTC-BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->market()->getOrderBook([
'instrument'=>'LTC-BTC',
'limit'=>10
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->market()->getOhlcv([
'instrument'=>'LTC-BTC',
'granularity'=>'30m'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->market()->getTradingFeeSchedules();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->market()->getWithdrawalFees([
'currency'=>'LTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
$crex=new Crex($key,$secret);
try {
$result=$crex->account()->getBalance([
//'currency'=>'FREE'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->account()->getDepositAddress([
'currency'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->account()->getDepositAddress([
'currency'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->account()->getMoneyTransfers();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
$crex=new Crex($key,$secret);
try {
$result=$crex->trading()->postPlaceOrder([
'instrument'=>'ETH-BTC',
'side'=>'buy',
'type'=>'limit',
'volume'=>'100',
'price'=>'0.01',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->trading()->getOrderStatus([
'id'=>'xxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->trading()->getOrderTrades([
'id'=>'xxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->trading()->postCancelOrdersById([
//'id'=>'xxxxxxxxxx'
'id'=>['111111','22222222']
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->trading()->getOrderHistory();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$crex->trading()->getTradeHistory();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}