所有的接口方式初始化与gate提供的接口方式一样,详细请看src/api
大部分的接口已经完成,使用者可以根据我的设计方案继续扩展,欢迎与我一起迭代它。
Exchanges 它包含以下所有交易所,强烈推荐使用该SDK。
composer require linwj/gate
支持更多的请求设置
$gate=new GateSpot();//默认API V4
$gate=new GateSpotV2();//默认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
更多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
更多API请查看 more