The official address API2 API4
All interface methods are initialized the same as those provided by Bitmex. See details src/api
Most of the interface is now complete, and the user can continue to extend it based on my design, working with me to improve it.
Exchanges It includes all of the following exchanges and is highly recommended.
composer require linwj/gate
Support for more request Settings
$gate=new GateSpot();//defult api v4
$gate=new GateSpotV2();//defult api v2
//You can set special needs
$gate->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,
]);
Market related API More
$gate=new GateSpot();
try {
$result=$gate->market()->getTickers();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$gate->market()->getOrderBook([
'currency_pair'=>'BTC_USDT'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$gate->market()->getTrades([
'currency_pair'=>'BTC_USDT'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$gate->market()->getCandlesticks([
'currency_pair'=>'BTC_USDT'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
Order API V4 More
$gate=new GateSpot($key,$secret);
//bargaining transaction
try {
$result=$gate->order()->post([
//'text'=>'t-xxxxxxxxxx',//custom ID
'currency_pair'=>'BTC_USDT',
'type'=>'limit',
'side'=>'buy',
'amount'=>'0.1',
'price'=>'4000',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
//track the order
try {
$result=$gate->order()->get([
'currency_pair'=>'BTC_USDT',
'order_id'=>'xxxxxxxxxx',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
//cancellation of order
try {
$result=$gate->order()->delete([
'currency_pair'=>'BTC_USDT',
'order_id'=>'xxxxxxxxxx',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
More Test more
More Api more
Market related API More
$gate=new GateFuture();
$gate=new GateDelivery();
try {
$result=$gate->market()->getTickers(['settle'=>'btc']);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$gate->market()->getOrderBook([
'settle'=>'btc',
'contract'=>'BTC_USD'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$gate->market()->getTrades([
'settle'=>'btc',
'contract'=>'BTC_USD'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$gate->market()->getCandlesticks([
'settle'=>'btc',
'contract'=>'BTC_USD'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
Order API V4 More
$gate=new GateFuture($key,$secret);
$gate=new GateDelivery($key,$secret);
//bargaining transaction
try {
$result=$gate->order()->post([
//'text'=>'t-xxxxxxxxxx',//custom ID
'settle'=>'btc',
'contract'=>'BTC_USD',
'size'=>'1',
'price'=>'4000',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
//track the order
try {
$result=$gate->order()->get([
'settle'=>'btc',
'order_id'=>'xxxxxxxxxx',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
//cancellation of order
try {
$result=$gate->order()->delete([
'settle'=>'btc',
'order_id'=>'xxxxxxxxxx',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
Market related API More
$gate=new GateSpotV2();
try {
$result=$gate->publics()->pairs();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$gate->publics()->marketinfo();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
Private API V2 More
$gate=new GateSpotV2($key,$secret);
//bargaining transaction
try {
$result=$gate->privates()->buy([
'currencyPair'=>'btc_usdt',
'rate'=>'3000',
'amount'=>'0.01',
//'text'=>'t-xxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
//track the order
try {
$result=$gate->privates()->getOrder([
'currencyPair'=>'btc_usdt',
'orderNumber'=>'xxxxxxxxxx',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
//cancellation of order
try {
$result=$gate->privates()->cancelOrder([
'currencyPair'=>'btc_usdt',
'orderNumber'=>'xxxxxxxxxx',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
//more
try {
$result=$gate->privates()->balances();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$gate->privates()->depositAddress(['currency'=>'BTC']);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
More Test more
More Api more