PHP code example of linwj / bitget

1. Go to this page and download the library: Download linwj/bitget 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 / bitget example snippets


$bitget=new BitgetSpotV2($key,$secret,$passphrase);
//or
$bitget=new BitgetContractV2()($key,$secret,$passphrase);

//You can set special needs
$bitget->setOptions([
    //Set the request timeout to 60 seconds by default
    'timeout'=>10,
    
]);

$bitget=new BitgetSpotV2($key,$secret,$passphrase);

try {
    $result=$bitget->market()->getTickers([
        'symbol'=>'BTCUSDT',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$bitget->market()->getCandles([
        'symbol'=>'BTCUSDT',
        'granularity'=>'5min'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

$bitget=new BitgetSpotV2($key,$secret,$passphrase);

try {
    $result=$bitget->account()->getAssets();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}


$bitget=new BitgetSpot($key,$secret);

try {
    $result=$bitget->trade()->postPlaceOrder([
        'symbol'=>'BTCUSDT',
        'side'=>'sell',
        'orderType'=>'limit',
        'force'=>'gtc',

        'price'=>'66666',
        'size'=>'1',
        //'clientOid'=>'**************',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$bitget->trade()->getOrderInfo([
        //'orderId'=>'***************',
        'clientOid'=>'**************',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}