goodmagma/bybit-php-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

goodmagma/bybit-php-api

最新稳定版本:v0.7.0

Composer 安装命令:

composer require goodmagma/bybit-php-api

包简介

PHP SDK for ByBit V5 API

README 文档

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:

API Name Completed Since Doc Ref
Market API 100% v0.1.0 Market API Doc
Trade API 100% v0.1.0 Trade API Doc
Position API 100% v0.1.0 Position API Doc
Pre-Upgrade API 100% v0.2.0 Pre-Upgrade API Doc
Account API 100% v0.1.0 Account API Doc
Asset API 100% v0.2.0 Asset API Doc
User API 100% v0.1.0 Asset API Doc
Spot Leverage Token 100% v0.3.0 Spot Leverage Token API Doc
Spot Margin Trade (UTA) 100% v0.4.0 Spot Margin Trade (UTA) API Doc
Spot Margin Trade (Normal) 100% v0.4.0 Spot Margin Trade (Normal) API Doc
Institutional Lending 100% v0.5.0 Institutional Lending API Doc
C2C Lending 100% v0.5.0 C2C Lending API Doc
Broker 100% v0.6.0 Broker API Doc
WebSocket Stream 0% WebSocket Stream API Doc

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

Custom API Client

When you need to send request to an endpoint which is not implemented in the SDK, you can use the customApi()->request().

// Get Transferable Amount (Unified)
$params = ['coinName' => $coin];
$uri = 'v5/account/withdrawal';
$method = \ByBit\SDK\ApiRequest::METHOD_GET;
$transferableAmount = $bybitApi->customApi()->request($method, $uri, $params);

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.

统计信息

  • 总下载量: 5.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-12