PHPackages                             quocvu88/binance-connector-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. quocvu88/binance-connector-php

ActiveLibrary[API Development](/categories/api)

quocvu88/binance-connector-php
==============================

A fork of Binance Connector - A thin layer for Binance API in PHP

v0.0.2(1y ago)06MITPHPPHP &gt;=8.1.0

Since Sep 16Pushed 1y agoCompare

[ Source](https://github.com/quocvu88/binance-connector-php)[ Packagist](https://packagist.org/packages/quocvu88/binance-connector-php)[ Docs](https://github.com/quocvu88/binance-connector-php)[ RSS](/packages/quocvu88-binance-connector-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (3)Used By (0)

Binance Connector PHP
=====================

[](#binance-connector-php)

This is a thin library that working as a connector to the Binance public API.

Installation
------------

[](#installation)

```
composer require binance/binance-connector-php
```

How to use
----------

[](#how-to-use)

```
require_once 'vendor/autoload.php';

$client = new \Binance\Spot();
$response = $client->time();
echo json_encode($response);

$client = new \Binance\Spot(['key' => $key, 'secret' => $secret]);
$response = $client->account();
echo json_encode($response);
```

Please find `examples` folder for more endpoints

### RSA Signature

[](#rsa-signature)

RSA signature is supported.

```
# RSA Key(Unencrypted) Authentication
$key = ''; # api key is also required
$privateKey = 'file:///path/to/rsa/private/key.pem';

$client = new \Binance\Spot([
    'key'  => $key,
    'privateKey'  => $privateKey, # pass the key file directly
    'baseURL' => 'https://testnet.binance.vision'
]);

# RSA key(Encrypted) Authentication
$key = '';
$encryptedPrivateKey = 'file:///path/to/rsa/private/key.pem';
$privateKey = openssl_pkey_get_private($encryptedPrivateKey, 'password');

$client = new \Binance\Spot([
    'key'  => $key,
    'privateKey'  => $privateKey,
    'baseURL' => 'https://testnet.binance.vision'
]);
```

### Testnet

[](#testnet)

The [spot testnet](https://testnet.binance.vision/) is available. In order to test on testnet:

```
$client = new \Binance\Spot([
    'baseURL' => 'https://testnet.binance.vision'
]);
```

### RecvWindow

[](#recvwindow)

From Binance API, recvWindow is available for all endpoints require signature. By default, it's 5000ms. You are allowed to set this parameter to any value less than 60000, number beyond this limit will receive error from Binance server.

```
$client = new \Binance\Spot(['key' => $key, 'secret' => $secret]);
$response = $client->getOrder('BNBUSDT', [
        'orderId'    => '11',
        'recvWindow' => 10000
    ]
);
```

### Optional parameters

[](#optional-parameters)

For the optional parameters in the endpoint, pass exactly the field name from API document into the optional parameter array. e.g

```
$response = $client->cancelOCOOrder('BNBUSDT',
    [
        'orderListId' => '12'
    ]
);
```

The mandartory parameter is validated in the library level, missing required parameter will throw `Binance\Exception\MissingArgumentException`.

### Timeout

[](#timeout)

Time out in seconds.

```
$client = new \Binance\Spot(['timeout' => 0.5]);

$response = $client->time();

echo json_encode($response);
```

### Display meta info

[](#display-meta-info)

Binance API server returns weight usage in the header of each response. This is very useful to indentify the current usage. To reveal this value, simpily intial the client with show\_weight\_usage=True as:

```
$client = new \Binance\Spot(['showWeightUsage' => true]);
$response = $client->time();
echo json_encode($response);
```

this will returns:

```
{"data":{"serverTime":1590579807751},"weight_usage":{"x-mbx-used-weight":["2"],"x-mbx-used-weight-1m":["2"]}}
```

It's also able to print out all headers, which may be very helpful for debug:

```
$client = new \Binance\Spot(['showHeader' => true]);
$response = $client->time();
echo json_encode($response);
```

the returns will be like:

```
{"data":{"serverTime":1590579942001},"header":{"Content-Type":["application/json;charset=utf-8"],"Transfer-Encoding":["chunked"],...}}
```

Websocket
---------

[](#websocket)

```
$client = new \Binance\Websocket\Spot();

$callbacks = [
    'message' => function($conn, $msg){
        echo $msg.PHP_EOL;
    },
    'ping' => function($conn, $msg) {
        echo "received ping from server".PHP_EOL;
    }
];

$client->aggTrade('btcusdt', $callbacks);
```

It's able to provide a customlized websocket connector.

```
$loop = \React\EventLoop\Factory::create();
$reactConnector = new \React\Socket\Connector($loop);
$connector = new \Ratchet\Client\Connector($loop, $reactConnector);
$client = new \Binance\Websocket\Spot(['wsConnector' => $connector]);

$callbacks = [
    'message' => function($conn, $msg){
        echo "received message".PHP_EOL;
    },
    'pong' => function($conn) {
        echo "received pong from server".PHP_EOL;
    },
    'ping' => function($conn) {
        echo "received ping from server".PHP_EOL;
    },
    'close' => function($conn) {
        echo "receive closed.".PHP_EOL;
    }
];

$client->miniTicker('btcusdt', $callbacks);

# send ping to server intervally
$loop->addPeriodicTimer(2, function () use ($client) {
    $client->ping();
    echo "ping sent ".PHP_EOL;
});

$loop->run();
```

Listen to combined stream:

```
$client->combined([
    'btcusdt@miniTicker',
    'ethusdt@miniTicker'
], $callbacks);
```

Test
----

[](#test)

```
# install the packages
composer install

vendor/bin/phpunit
```

Limitation
----------

[](#limitation)

Futures and Vanilla Options APIs are not supported:

- /fapi/\*
- /dapi/\*
- /vapi/\*
- Associated Websocket Market and User Data Streams

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

[](#contributing)

Contributions are welcome. If you've found a bug within this project, please open an issue to discuss what you would like to change. If it's an issue with the API, please open a topic at Binance Developer Community

License
-------

[](#license)

MIT

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~0 days

Total

2

Last Release

599d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cbc5e2e4e934a1c9fffad20d021fbefbf651b225100b3ca8e2917adfebfcaf1?d=identicon)[quocvu88](/maintainers/quocvu88)

---

Top Contributors

[![2pd](https://avatars.githubusercontent.com/u/365354?v=4)](https://github.com/2pd "2pd (21 commits)")[![alplabin](https://avatars.githubusercontent.com/u/122352306?v=4)](https://github.com/alplabin "alplabin (13 commits)")[![selviler](https://avatars.githubusercontent.com/u/56368718?v=4)](https://github.com/selviler "selviler (11 commits)")[![quocvu88](https://avatars.githubusercontent.com/u/6780106?v=4)](https://github.com/quocvu88 "quocvu88 (2 commits)")[![tantialex](https://avatars.githubusercontent.com/u/17701918?v=4)](https://github.com/tantialex "tantialex (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/quocvu88-binance-connector-php/health.svg)

```
[![Health](https://phpackages.com/badges/quocvu88-binance-connector-php/health.svg)](https://phpackages.com/packages/quocvu88-binance-connector-php)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[alexacrm/dynamics-webapi-toolkit

Web API toolkit for Microsoft Dynamics 365 and Dynamics CRM

81324.1k1](/packages/alexacrm-dynamics-webapi-toolkit)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)[keboola/storage-api-client

Keboola Storage API PHP Client

10387.5k25](/packages/keboola-storage-api-client)

PHPackages © 2026

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