1. Go to this page and download the library: Download tigusigalpa/bitget-php 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/ */
tigusigalpa / bitget-php example snippets
use Tigusigalpa\Bitget\Facades\Bitget;
$tickers = Bitget::market()->getTickers('SPOT', 'BTCUSDT');
use Tigusigalpa\Bitget\Client;
$client = new Client(
apiKey: getenv('BITGET_API_KEY'),
secretKey: getenv('BITGET_SECRET_KEY'),
passphrase: getenv('BITGET_PASSPHRASE'),
);
$tickers = $client->market()->getTickers('SPOT', 'BTCUSDT');
$client = new Client(
apiKey: config('bitget.api_key'),
secretKey: config('bitget.secret_key'),
passphrase: config('bitget.passphrase'),
demoTrading: true,
);
// Guard order placement behind an explicit opt-in — never wire this to
// production credentials without removing the gate deliberately.
if (getenv('BITGET_ENABLE_TRADING') === '1') {
$client->trade()->placeOrder([
'category' => 'SPOT',
'symbol' => 'BTCUSDT',
'side' => 'buy',
'orderType' => 'limit',
'price' => '10000', // deliberately far below market so it won't fill
'qty' => '0.001',
]);
}
use Tigusigalpa\Bitget\Exceptions\AuthenticationException;
use Tigusigalpa\Bitget\Exceptions\InsufficientFundsException;
use Tigusigalpa\Bitget\Exceptions\RateLimitException;
use Tigusigalpa\Bitget\Exceptions\BitgetException;
try {
$client->trade()->placeOrder([...]);
} catch (AuthenticationException $e) {
// invalid API key/secret/passphrase
} catch (InsufficientFundsException $e) {
// not enough balance/margin
} catch (RateLimitException $e) {
// back off and retry
} catch (BitgetException $e) {
// anything else; $e->bitgetCode / $e->rawResponse are available
}