PHP code example of goodmagma / bybit-php-api

1. Go to this page and download the library: Download goodmagma/bybit-php-api 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/ */

    

goodmagma / bybit-php-api example snippets




use ByBit\SDK\ByBitApi;

//create public API on real environment
$bybitApi = new ByBitApi();

//create public API on sandbox environment
$bybitApi = new ByBitApi('', '', ByBitApi::PROD_API_URL);



use ByBit\SDK\ByBitApi;

//Your API Key
$api_key = 'XXXXXXXXXX';

//Your Secret Key
$api_secret = 'XXXXXXXXXX';

//Your Host
//$host = ByBit\SDK\ByBitApi::TESTNET_API_URL;
//$host = ByBit\SDK\ByBitApi::DEMO_API_URL;
$host = ByBit\SDK\ByBitApi::PROD_API_URL;


//create private API
$bybitApi = new ByBitApi($api_key, $api_secret, $host);

// Get Position Info
$params = ["category" => "linear", "symbol" => "BTCUSDT"];
$positions = $bybitApi->positionApi()->getPositionInfo($params);

var_dump($positions);

composer 

php Position.php