goodmagma/bybit-php-api

PHP SDK for ByBit V5 API

v0.7.0 2024-08-26 14:46 UTC

This package is auto-updated.

Last update: 2024-10-26 15:08:37 UTC


README

Latest Version Latest commit PHP Version Packagist Downloads License

PHP SDK for ByBit V5 API

The detailed API documentation can be found here https://bybit-exchange.github.io/docs/v5/intro. In order to receive the latest API change notifications, please Watch this repository.

Implementation Status

This project is under development, and already used in production, but only the main API's are covered. I promise I'll do my best to complete the client with all ByBit V5 API's, but if you have time, any contributions are welcome!

Actually the API's completion status are the following:

Install

composer require goodmagma/bybit-php-api

Getting started

Create Public API Client

include '../vendor/autoload.php';

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

Create Private API Client

include '../vendor/autoload.php';

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

Use API Client

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

var_dump($positions);

See additional examples

Run Examples

Go to examples directory and copy key_secret.php.sample to key_secret.php. Configure key_secret.php with your API Keys and run example like:

php Position.php

Changelog

See CHANGELOG.md for full project log.

Contributing

Contributions are what makes the open source community such an amazing place to learn, inspire and create. Any contributions you make are greatly appreciated.

  • Give us a star ⭐
  • Fork and Clone! Awesome
  • Select existing issues or create a new issue and give us a PR with your bugfix or improvement after. We love it ❤️

If you want to make a PR:

  1. Fork the Project and checkout develop branch
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.