|
| 1 | +# WhiteBIT PHP SDK |
| 2 | + |
| 3 | +[](https://packagist.org/packages/your-vendor/your-sdk) |
| 4 | +[](LICENSE) |
| 5 | + |
| 6 | +Official PHP SDK for the [WhiteBIT](https://whitebit.com/) API. ([WhiteBIT API Documentation](docs.whitebit.com)) |
| 7 | + |
| 8 | +## Requirements |
| 9 | +* `PHP 8.2` or higher |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +You can install this SDK via [Composer](https://getcomposer.org/): |
| 14 | + |
| 15 | +```bash |
| 16 | +composer require whitebit/php |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +### Plain PHP with autoload |
| 22 | +```php |
| 23 | +<?php |
| 24 | + |
| 25 | +use WhiteBIT\Sdk\Connectors\WhiteBITConnector; |
| 26 | +use WhiteBIT\Sdk\Connectors\ConnectorConfig; |
| 27 | +use WhiteBIT\Sdk\Requests\General\V1\KlineRequest; |
| 28 | + |
| 29 | +$connector = new WhiteBITConnector( |
| 30 | + new ConnectorConfig('api_key', 'api_secret') |
| 31 | +); |
| 32 | + |
| 33 | +$connector->send(new KlineRequest('BTC_USDT')) |
| 34 | +``` |
| 35 | + |
| 36 | +### Laravel |
| 37 | +Package automatically injects `WhiteBITServiceProvider.php` into your app. |
| 38 | + |
| 39 | +#### Publish config |
| 40 | +```shell |
| 41 | +php artisan vendor:publish --provider="WhiteBIT\Sdk\WhiteBITServiceProvider" |
| 42 | +``` |
| 43 | + |
| 44 | +### Environment variables |
| 45 | +```dotenv |
| 46 | +WHITEBIT_PUBLIC_KEY= |
| 47 | +WHITEBIT_SECRET_KEY= |
| 48 | +``` |
| 49 | + |
| 50 | +#### Usage |
| 51 | +```php |
| 52 | +namespace App\Http\Controllers; |
| 53 | + |
| 54 | +use Illuminate\View\View; |
| 55 | +use WhiteBIT\Sdk\Connectors\WhiteBITConnector; |
| 56 | +use WhiteBIT\Sdk\Requests\General\V1\KlineRequest; |
| 57 | + |
| 58 | +class ExampleController extends Controller |
| 59 | +{ |
| 60 | + |
| 61 | + public function show(WhiteBITConnector $connector): View |
| 62 | + { |
| 63 | + $response = $connector->send(new KlineRequest('BTC_USDT')); |
| 64 | + |
| 65 | + return response()->json( |
| 66 | + $response->json() |
| 67 | + ); |
| 68 | + } |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +#### Notes |
| 73 | +`WhiteBITServiceProvider` registers `WhiteBITConnector` as singleton, use it with care in runtimes like `openswoole`, `roadrunner` etc. |
| 74 | + |
| 75 | +## Available requests |
| 76 | + |
| 77 | +``` |
| 78 | +Requests |
| 79 | +├── General |
| 80 | +│ ├── AssetsRequest.php |
| 81 | +│ ├── CollateralMarketsRequest.php |
| 82 | +│ ├── FeeRequest.php |
| 83 | +│ ├── FutureMarketsRequest.php |
| 84 | +│ ├── HealthRequest.php |
| 85 | +│ ├── MarketActivityRequest.php |
| 86 | +│ ├── MarketsRequest.php |
| 87 | +│ ├── OrderBookRequest.php |
| 88 | +│ ├── TimeRequest.php |
| 89 | +│ ├── TradesRequest.php |
| 90 | +│ └── V1 |
| 91 | +│ ├── KlineRequest.php |
| 92 | +│ ├── MarketActivityRequest.php |
| 93 | +│ ├── SingleMarketActivityRequest.php |
| 94 | +│ └── TradeHistoryRequest.php |
| 95 | +└── Private |
| 96 | + ├── AddressRequest.php |
| 97 | + ├── Codes |
| 98 | + │ ├── ApplyCodeRequest.php |
| 99 | + │ ├── CodesHistoryRequest.php |
| 100 | + │ ├── CreateCodeRequest.php |
| 101 | + │ └── MyCodesRequest.php |
| 102 | + ├── Main |
| 103 | + │ ├── CreateNewAddressRequest.php |
| 104 | + │ ├── CreateWithdrawPayRequest.php |
| 105 | + │ ├── CreateWithdrawRequest.php |
| 106 | + │ ├── FiatDepositUrlRequest.php |
| 107 | + │ ├── HistoryRequest.php |
| 108 | + │ └── TransferBetweenBalancesRequest.php |
| 109 | + ├── MainBalanceRequest.php |
| 110 | + └── Trade |
| 111 | + ├── Spot |
| 112 | + │ ├── DealsHistoryRequest.php |
| 113 | + │ ├── OrderDealsRequest.php |
| 114 | + │ ├── OrderHistoryRequest.php |
| 115 | + │ ├── Orders |
| 116 | + │ │ ├── CancelOrderRequest.php |
| 117 | + │ │ ├── CreateBulkLimitOrderRequest.php |
| 118 | + │ │ ├── CreateLimitOrderRequest.php |
| 119 | + │ │ ├── CreateMarketOrderRequest.php |
| 120 | + │ │ ├── CreateStockMarketOrderRequest.php |
| 121 | + │ │ ├── CreateStopLimitOrderRequest.php |
| 122 | + │ │ └── CreateStopMarketOrderRequest.php |
| 123 | + │ └── UnexecutedOrdersRequest.php |
| 124 | + ├── StatusKillSwitchRequest.php |
| 125 | + ├── SyncKillSwitchRequest.php |
| 126 | + └── TradeBalanceRequest.php |
| 127 | +``` |
0 commit comments