PHPackages                             dalvin1991/binance\_client\_api - 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. dalvin1991/binance\_client\_api

ActiveLibrary[API Development](/categories/api)

dalvin1991/binance\_client\_api
===============================

5311PHP

Since Oct 22Pushed 8y agoCompare

[ Source](https://github.com/dalvin1991/BinanceClientAPI)[ Packagist](https://packagist.org/packages/dalvin1991/binance_client_api)[ RSS](/packages/dalvin1991-binance-client-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Binance API
===============

[](#php-binance-api)

This PHP plugin can hep you integrate with the Binance Excahnge API easier. Binance API: \*Example is inside demo folder, you may uncommend the code and try the api by copy the indexphp to your project root folder.

#### Installation

[](#installation)

```
*Note Require to install composer which can found in https://getcomposer.org/

composer require dalvin1991/binance_client_api dev-master

```

#### Getting started

[](#getting-started)

```
require 'vendor/autoload.php'; //the directory of the autoload.php in vendor folder
$api = new BinanceClientAPI\API("",""); //the initialize of the API instance
```

#### Get latest price for each cryptocurrency

[](#get-latest-price-for-each-cryptocurrency)

```
echo "getPrices()";
$ticker = $api->getPrices();
echo "".print_r($ticker,true)."";
```

#### Get all of your balance for all cryptocurrency

[](#get-all-of-your-balance-for-all-cryptocurrency)

```
echo "getBalances()";
$balances = $api->getBalances($ticker);
echo "".print_r($balances,true)."";
```

#### Get all of cryptocurrency bid/ask prices

[](#get-all-of-cryptocurrency-bidask-prices)

```
echo "getBookPrices()";
$bookPrices = $api->getBookPrices();
echo "".print_r($bookPrices,true)."";
```

#### Place a Buy LIMIT order

[](#place-a-buy-limit-order)

```
$quantity = 1;
$price = 0.0005;
$pair = "BNBBTC";
$order = $api->buyOrder($pair, $quantity, $price);
```

#### Place a Sell LIMIT order

[](#place-a-sell-limit-order)

```
$quantity = 1;
$price = 0.0005;
$pair = "BNBBTC";
$order = $api->sellOrder($pair, $quantity, $price);
```

#### Place a Buy MARKET order

[](#place-a-buy-market-order)

```
$quantity = 1;
$pair = "BNBBTC";
$order = $api->buyOrder($pair, $quantity, 0, "MARKET");
```

#### Place a Sell MARKET order

[](#place-a-sell-market-order)

```
$quantity = 1;
$pair = "BNBBTC";
$order = $api->buyOrder($pair, $quantity, 0, "MARKET");
```

#### Place a STOP LOSS order

[](#place-a-stop-loss-order)

```
$quantity = 1;
$price = 0.5; // Target btc sell value
$stopPrice = 0.4; // Sell immediately if price goes below 0.4 btc with market order
$pair = "BNBBTC";
$order = $api->sellOrder($pair, $quantity, $price, "LIMIT", ["stopPrice"=>$stopPrice]);
echo "".print_r($order,true)."";
```

#### Place an ICEBERG order

[](#place-an-iceberg-order)

```
$quantity = 1;
$price = 0.5;
$icebergQty = 10;
$pair = "BNBBTC";
$order = $api->sellOrder($pair, $quantity, $price, "LIMIT", ["icebergQty"=>$icebergQty]);
echo "".print_r($order,true)."";
```

#### Complete History Complete Trade

[](#complete-history-complete-trade)

```
echo "getHistoryOrders()";
$pair="ETHBTC";
$history = $api->getHistoryOrders($pair);
echo "".print_r($history,true)."";
```

#### Get Market Depth

[](#get-market-depth)

```
echo "getDepth()";
$pair="ETHBTC";
$depth = $api->getDepth($pair);
echo "".print_r($depth,true)."";
```

#### Get Open Orders

[](#get-open-orders)

```
echo "getOpenOrders()";
$pair="BTCUSDT";
$openorders = $api->getOpenOrders($pair);
echo "".print_r($openorders,true)."";
```

#### Get Order Status

[](#get-order-status)

```
echo "getOrderStatus()";
$orderid = ; //orderid can get from getOpenOrders() method
$pair="BTCUSDT";
$orderstatus = $api->getOrderStatus($pair, $orderid);
echo "".print_r($orderstatus,true)."";
```

#### Cancel an Order

[](#cancel-an-order)

```
echo "cancelOrder()";
$pair="BTCUSDT";
$orderid = ; //orderid can get from getOpenOrders() method
$response = $api->cancelOrder($pair, $orderid);
echo "".print_r($response,true)."";
```

#### Aggregate Trades List

[](#aggregate-trades-list)

```
echo "getAggTrades()";
$pair="ETHBTC";
$trades = $api->getAggTrades($pair);
echo "".print_r($trades,true)."";
```

#### Get ALl Order (active, canceled, filled) for the pair requested

[](#get-all-order-active-canceled-filled-for-the-pair-requested)

```
$pair="BTCUSDT";
$orders = $api->getOrders($pair);
echo "".print_r($orders,true)."";
```

#### Get candlestick data for the pair requested.

[](#get-candlestick-data-for-the-pair-requested)

```
//Interval: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M
echo "getCandleSticks()";
$interval="15m";
$pair="ETHBTC";
$ticks = $api->getCandleSticks($pair, $interval);
echo "".print_r($ticks,true)."";
```

WebSocket API
-------------

[](#websocket-api)

#### Realtime Chart Cache via WebSockets

[](#realtime-chart-cache-via-websockets)

```
$api->getChart(["BNBBTC"], "15m", function($api, $symbol, $chart) {
    echo "{$symbol} chart update\n";
    echo "".print_r($chart,true)."";
//});
```

#### Trade Updates via WebSocket

[](#trade-updates-via-websocket)

```
$api->trades(["BNBBTC"], function($api, $symbol, $trades) {
    echo "{$symbol} trades update".PHP_EOL;
    print_r($trades);
});
```

#### Realtime updated depth cache via WebSockets

[](#realtime-updated-depth-cache-via-websockets)

```
$api->depthCache(["BNBBTC"], function($api, $symbol, $depth) {
	//the depth value is inside the $depth
    echo "{$symbol} depth cache update\n";
    $limit = 10; // Show how many depth level for asks/bids
    $sorted = $api->sortDepth($symbol, $limit);
    $bid = $api->first($sorted['bids']);
    $ask = $api->first($sorted['asks']);
    echo $api->displayDepth($sorted);
    echo "ask: {$ask}";
    echo "bid: {$bid}";
});
```

#### Get realtime updated depth cache via WebSockets

[](#get-realtime-updated-depth-cache-via-websockets)

```
$api->depthCache(["BNBBTC"], function($api, $symbol, $depth) {
	//the depth value is inside the $depth
    echo "{$symbol} depth cache update\n";
    $limit = 10; // Show how many depth level for asks/bids
    $sorted = $api->sortDepth($symbol, $limit);
    $bid = $api->first($sorted['bids']);
    $ask = $api->first($sorted['asks']);
    echo $api->displayDepth($sorted);
    echo "ask: {$ask}";
    echo "bid: {$bid}";
});
```

#### Get realtime chart data via WebSockets

[](#get-realtime-chart-data-via-websockets)

```
//Interval: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M
$api->getChart(["BNBBTC"], "15m", function($api, $symbol, $chart) {
    echo "{$symbol} chart update\n";
    echo "".print_r($chart,true)."";
});
```

#### Get realtime updated done trade data via WebSockets

[](#get-realtime-updated-done-trade-data-via-websockets)

```
$api->getTradesA(["BTCUSDT"], function($api, $symbol, $trades) {
    echo "{$symbol} trades update".PHP_EOL;
    echo "".print_r($trades,true)."";
});
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7418f9fb13fc6ebc72d4c4adad7aaed5bc2b823da4848f84afb8b8e93173bbbe?d=identicon)[dalvin1991](/maintainers/dalvin1991)

---

Top Contributors

[![dalvin1991](https://avatars.githubusercontent.com/u/16516897?v=4)](https://github.com/dalvin1991 "dalvin1991 (20 commits)")

### Embed Badge

![Health badge](/badges/dalvin1991-binance-client-api/health.svg)

```
[![Health](https://phpackages.com/badges/dalvin1991-binance-client-api/health.svg)](https://phpackages.com/packages/dalvin1991-binance-client-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

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