PHPackages                             tigusigalpa/bitget-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tigusigalpa/bitget-php

ActiveLibrary[API Development](/categories/api)

tigusigalpa/bitget-php
======================

A production-grade PHP/Laravel SDK for the Bitget Unified Trading Account (UTA) API v3.

v1.0.2(today)80MITPHPPHP ^8.2CI passing

Since Aug 9Pushed today1 watchersCompare

[ Source](https://github.com/tigusigalpa/bitget-php)[ Packagist](https://packagist.org/packages/tigusigalpa/bitget-php)[ Docs](https://github.com/tigusigalpa/bitget-php)[ RSS](/packages/tigusigalpa-bitget-php/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Bitget PHP SDK
==============

[](#bitget-php-sdk)

[![Bitget PHP Laravel SDK](https://camo.githubusercontent.com/9201a63d866b7005421bda1fe078500cc1d660013f691f3d263ec701fdf8c743/68747470733a2f2f692e706f7374696d672e63632f426e634a79466d572f6269746765742d7068702d73646b2d6769746875622e6a7067)](https://camo.githubusercontent.com/9201a63d866b7005421bda1fe078500cc1d660013f691f3d263ec701fdf8c743/68747470733a2f2f692e706f7374696d672e63632f426e634a79466d572f6269746765742d7068702d73646b2d6769746875622e6a7067)

[![PHP Version](https://camo.githubusercontent.com/08f365152a45f6abffd9e4bfafa3b608a0733bf3cf58d94ea2fecc0fef91638e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322d373737626234)](composer.json)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)[![Laravel](https://camo.githubusercontent.com/ee58d8363d03f0d51893e1889947a72718e75b4933fcf5071f338c9242e4d0b0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302532302537432532303131253230253743253230313225323025374325323031332d666632643230)](composer.json)

A production-grade PHP SDK for the [Bitget Unified Trading Account (UTA) API v3](https://www.bitget.com/api-doc/uta/intro), with seamless Laravel 10-13 integration. Phase 1 covers Market, Account, and Trade REST services plus a reconnecting WebSocket client with a pluggable transport.

**Package:** a matching Go SDK is available at [tigusigalpa/bitget-go](https://github.com/tigusigalpa/bitget-go).

What's inside
-------------

[](#whats-inside)

- PHP 8.2+, `declare(strict_types=1)` everywhere, readonly constructor properties
- Strings for every price/quantity/PnL/fee field — no float rounding errors
- Guzzle-based HTTP transport with an injectable `GuzzleHttp\Client` for tests/proxies
- PSR-3 logging (defaults to a no-op `NullLogger`); credentials are never logged
- A typed exception hierarchy (`AuthenticationException`, `RateLimitException`, `InvalidParameterException`, `InsufficientFundsException`, `OrderNotFoundException`) carrying Bitget's raw error code
- A `WebsocketClient` with pluggable transport (`ConnectionInterface`) — ships with a synchronous `textalk/websocket` adapter; implement the interface yourself to run under ReactPHP, Amp, or Laravel Octane's event loop
- Laravel service provider, publishable config, and `Bitget` facade — auto-discovered, but the SDK has no hard `illuminate/*` dependency outside Laravel apps

Install
-------

[](#install)

```
composer require tigusigalpa/bitget-php
```

### Laravel setup

[](#laravel-setup)

The service provider and `Bitget` facade are auto-discovered. Publish the config file:

```
php artisan vendor:publish --tag=bitget-config
```

```
BITGET_API_KEY=your-api-key
BITGET_SECRET_KEY=your-secret-key
BITGET_PASSPHRASE=your-passphrase
BITGET_DEMO=false
```

```
use Tigusigalpa\Bitget\Facades\Bitget;

$tickers = Bitget::market()->getTickers('SPOT', 'BTCUSDT');
```

### Plain PHP (no Laravel)

[](#plain-php-no-laravel)

```
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');
```

Configuration
-------------

[](#configuration)

`config/bitget.php` keyEnv varDefault`api_key``BITGET_API_KEY``''``secret_key``BITGET_SECRET_KEY``''``passphrase``BITGET_PASSPHRASE``''``demo``BITGET_DEMO``false``base_url``BITGET_BASE_URL``https://api.bitget.com``locale``BITGET_LOCALE``en-US`REST API coverage (Phase 1)
---------------------------

[](#rest-api-coverage-phase-1)

CategoryMethodsDocsMarket (public)`getInstruments`, `getTickers`, `getOrderBook`[Instruments](https://www.bitget.com/api-doc/uta/public/Instruments) · [Tickers](https://www.bitget.com/api-doc/uta/public/Tickers) · [OrderBook](https://www.bitget.com/api-doc/uta/public/OrderBook)Account (private)`getAssets`, `getSettings`, `setLeverage`[Get-Account](https://www.bitget.com/api-doc/uta/account/Get-Account) · [Get-Account-Setting](https://www.bitget.com/api-doc/uta/account/Get-Account-Setting) · [Change-Leverage](https://www.bitget.com/api-doc/uta/account/Change-Leverage)Trade (private)`placeOrder`, `modifyOrder`, `cancelOrder`, `getOpenOrders`, `getOrderHistory`, `getPositions`[Place-Order](https://www.bitget.com/api-doc/uta/trade/Place-Order) · [Modify-Order](https://www.bitget.com/api-doc/uta/trade/Modify-Order) · [Cancel-Order](https://www.bitget.com/api-doc/uta/trade/Cancel-Order) · [Get-Order-Pending](https://www.bitget.com/api-doc/uta/trade/Get-Order-Pending) · [Get-Order-History](https://www.bitget.com/api-doc/uta/trade/Get-Order-History) · [Get-Position](https://www.bitget.com/api-doc/uta/trade/Get-Position)Full mapping with HTTP methods and paths: [docs/endpoints.md](docs/endpoints.md).

WebSocket
---------

[](#websocket)

```
use Tigusigalpa\Bitget\WebsocketClient;

$ws = new WebsocketClient(WebsocketClient::DEFAULT_PUBLIC_URL);
$ws->connect();
$ws->subscribe(['instType' => 'SPOT', 'topic' => 'ticker', 'symbol' => 'BTCUSDT']);

$ws->listen(function (array $push) {
    echo json_encode($push), PHP_EOL;
});
```

For private channels (e.g. order fills), pass credentials to the constructor — `connect()` authenticates automatically:

```
$ws = new WebsocketClient(
    url: WebsocketClient::DEFAULT_PRIVATE_URL,
    apiKey: config('bitget.api_key'),
    secretKey: config('bitget.secret_key'),
    passphrase: config('bitget.passphrase'),
);
$ws->connect();
$ws->subscribe(['instType' => 'UTA', 'topic' => 'fast-fill', 'symbol' => 'default']);
$ws->listen(fn (array $push) => /* handle fill */ null);
```

`listen()` blocks the current process, answers Bitget's text-frame ping/pong heartbeat, and — on an unexpected disconnect — reconnects with exponential backoff (1s → 60s cap) and resubscribes every previously active channel. The default transport (`TextalkConnection`) is synchronous; to run under a non-blocking event loop (ReactPHP, Amp, Laravel Octane), implement `Tigusigalpa\Bitget\WebSocket\ConnectionInterface` and pass it as `WebsocketClient`'s `$connection` constructor argument.

Implemented private channel: [`fast-fill`](https://www.bitget.com/api-doc/uta/websocket/private/Fast-Fill-Channel). Other channels work through the same `subscribe()`/`listen()` API; see [docs/endpoints.md](docs/endpoints.md).

Demo trading
------------

[](#demo-trading)

Set `demo: true` (or `BITGET_DEMO=true`) together with a **Demo API key** from the Bitget console to send `paptrading: 1` on every REST request, or use `WebsocketClient::DEMO_PUBLIC_URL`/`DEMO_PRIVATE_URL` for WebSocket. Always validate new code against demo credentials before pointing it at a live account:

```
$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',
    ]);
}
```

Errors
------

[](#errors)

```
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
}
```

Tests
-----

[](#tests)

```
composer install
vendor/bin/phpunit
```

Unit tests run fully offline against a mocked Guzzle transport (`MockHandler`) — no network access or credentials required.

Contributing
------------

[](#contributing)

1. Fork and branch off `main`.
2. Add/update tests for any behavior change (`vendor/bin/phpunit` must pass).
3. Every public method must include a `Docs:` line in its docblock linking to the exact Bitget API documentation page it implements.
4. Update [docs/endpoints.md](docs/endpoints.md) for new endpoints.

Security
--------

[](#security)

Found a vulnerability? Email  directly — please don't open a public issue.

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

Author
------

[](#author)

Igor Sazonov — [@tigusigalpa](https://github.com/tigusigalpa) —

Links
-----

[](#links)

- [Bitget UTA API docs](https://www.bitget.com/api-doc/uta/intro)
- [Repository](https://github.com/tigusigalpa/bitget-php)
- [Issues](https://github.com/tigusigalpa/bitget-php/issues)

---

*Not affiliated with Bitget. Test on demo before going live.*

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2721390?v=4)[Igor Sazonov](/maintainers/tigusigalpa)[@tigusigalpa](https://github.com/tigusigalpa)

---

Top Contributors

[![tigusigalpa](https://avatars.githubusercontent.com/u/2721390?v=4)](https://github.com/tigusigalpa "tigusigalpa (3 commits)")

---

Tags

apibitcoinbitcoin-corebitgetbitget-apibitget-api-clientcryptocryptocurrencylaravelltcnear-protocolnearprotocolphpapilaravelsdkcryptotradingbitgetuta

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tigusigalpa-bitget-php/health.svg)

```
[![Health](https://phpackages.com/badges/tigusigalpa-bitget-php/health.svg)](https://phpackages.com/packages/tigusigalpa-bitget-php)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.9k556.2M21.3k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k19](/packages/tempest-framework)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.7M7](/packages/avalara-avataxclient)[nutgram/nutgram

The Telegram bot library that doesn't drive you nuts

740315.8k8](/packages/nutgram-nutgram)[bushlanov-dev/max-bot-api-client-php

Max Bot API Client library

488.7k](/packages/bushlanov-dev-max-bot-api-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
