{"id":36969934,"url":"https://github.com/kleninmaxim/binance-api","last_synced_at":"2026-01-13T21:42:23.433Z","repository":{"id":184614604,"uuid":"666995226","full_name":"kleninmaxim/binance-api","owner":"kleninmaxim","description":"Binance API client for PHP","archived":false,"fork":false,"pushed_at":"2023-08-05T14:44:05.000Z","size":200,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"1.0","last_synced_at":"2025-09-16T20:46:10.828Z","etag":null,"topics":["api","binance","cryptocurrency","cryptocurrency-exchanges","php"],"latest_commit_sha":null,"homepage":"https://binance-docs.github.io/apidocs/spot/en","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kleninmaxim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null}},"created_at":"2023-07-16T09:37:44.000Z","updated_at":"2024-01-06T09:30:28.000Z","dependencies_parsed_at":"2023-07-29T10:23:30.820Z","dependency_job_id":null,"html_url":"https://github.com/kleninmaxim/binance-api","commit_stats":null,"previous_names":["kleninmaxim/binance-api"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kleninmaxim/binance-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kleninmaxim%2Fbinance-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kleninmaxim%2Fbinance-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kleninmaxim%2Fbinance-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kleninmaxim%2Fbinance-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kleninmaxim","download_url":"https://codeload.github.com/kleninmaxim/binance-api/tar.gz/refs/heads/1.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kleninmaxim%2Fbinance-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28401058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","binance","cryptocurrency","cryptocurrency-exchanges","php"],"created_at":"2026-01-13T21:42:22.798Z","updated_at":"2026-01-13T21:42:23.426Z","avatar_url":"https://github.com/kleninmaxim.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binance PHP API Client\n\n[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/kleninmaxim/binance-api/tests.yml?label=Tests)]([https://travis-ci.com/ccxt/ccxt](https://github.com/kleninmaxim/binance-api/actions/workflows/tests.yml))\n[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/kleninmaxim/binance-api/style.yml?label=StyleCI)](https://github.com/kleninmaxim/binance-api/actions/workflows/style.yml)\n[![Packagist License (custom server)](https://img.shields.io/packagist/l/kleninm/binance-api?style=flat-square)](https://github.com/kleninmaxim/binance-api#license)\n[![GitHub release (with filter)](https://img.shields.io/github/v/release/kleninmaxim/binance-api)](https://github.com/kleninmaxim/binance-api/releases)\n\nThe purpose of this project is to assist you in creating your own projects that interact with the [Binance SPOT API](https://binance-docs.github.io/apidocs/spot/en/).\n\nSupported in the current version [Wallet Endpoints](https://binance-docs.github.io/apidocs/spot/en/#wallet-endpoints),\n[Market Data Endpoints](https://binance-docs.github.io/apidocs/spot/en/#market-data-endpoints) and [Spot Account/Trade](https://binance-docs.github.io/apidocs/spot/en/#spot-account-trade)\n\n## Introduction\nThis project requires [php](https://www.php.net/) version more or equal 8.2. Also it requires [bcmath](https://www.php.net/manual/en/book.bc.php) extension and [guzzle](https://docs.guzzlephp.org/en/stable/) dependency\n\n## Installation\n\n```shell\ncomposer require kleninm/binance-api\n```\n\n## Quick start\nEvery original method's name in `\\BinanceApi\\Binance` class created by name from url after prefix `v1`, `v2` or `v3`.\n\nFor example, by table:\n\u003ctable\u003e\n   \u003ctr\u003e\u003ctd\u003e Link to endpoint \u003c/td\u003e \u003ctd\u003e Method name \u003c/td\u003e\u003c/tr\u003e\n   \n   \u003ctr\u003e\u003ctd\u003e\n\n   [Order Book](https://binance-docs.github.io/apidocs/spot/en/#order-book)\n   \n   \u003c/td\u003e\u003ctd\u003e\n   \n   ```php\n   $binance-\u003edepth($symbol, $limit);\n   ```\n   \u003c/td\u003e\u003c/tr\u003e\n   \n   \u003ctr\u003e\u003ctd\u003e\n\n   [Symbol Order Book Ticker](https://binance-docs.github.io/apidocs/spot/en/#symbol-order-book-ticker)\n\n   \u003c/td\u003e\u003ctd\u003e\n\n   ```php\n   $binance-\u003etickerBookTicker($symbol);\n   ``` \n   \u003c/td\u003e\u003c/tr\u003e\n\n   \u003ctr\u003e\u003ctd\u003e\n\n   [24hr Ticker Price Change Statistics](https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics)\n\n   \u003c/td\u003e\u003ctd\u003e\n\n   ```php\n   $binance-\u003eticker24hr($symbol, $symbols, $type);\n   ```\n   \u003c/td\u003e\u003c/tr\u003e\n\n   \u003ctr\u003e\u003ctd\u003e\n\n[Withdraw History (supporting network)](https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data)\n\n   \u003c/td\u003e\u003ctd\u003e\n\n   ```php\n   $binance-\u003ecapitalWithdrawHistory();\n   ```\n   \u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\nAll endpoints and their methods with parameters you can see in phpdoc in `\\BinanceApi\\Binance` class\n\nFull docs you can find in `documentation` folder of this repository\n\nLook at the [Basic](https://github.com/kleninmaxim/binance-api/tree/1.x/documentation/Basic.md) topic\nto learn more features\n\nLook at the [Digging deeper](https://github.com/kleninmaxim/binance-api/tree/1.x/documentation/Basic.md) topic\nif you want to dive deep into the mechanism and add more yourself customizations and scale functionality\n\nYou can go to the [Examples and Analogs](https://github.com/kleninmaxim/binance-api/tree/1.x/documentation/ExamplesAndAnalogs.md) topic\nto see more examples, include what each function returns\n\n## Simple start\n\n ```php\n $binance = new \\BinanceApi\\Binance();\n\n $fullResult = $binance-\u003edepth('BTCUSDT', 2);\n\n $orderbook = $fullResult['response']['data'];\n ```\n\n\u003cdetails\u003e\n \u003csummary\u003eView $fullResult variable\u003c/summary\u003e\n\n```\nArray\n(\n   [request] =\u003e Array\n      (\n         [url] =\u003e /api/v3/depth\n         [headers] =\u003e Array\n            (\n            )\n         [query] =\u003e Array\n            (\n               [symbol] =\u003e BTCUSDT\n               [limit] =\u003e 2\n            )\n         [body] =\u003e Array\n            (\n            )\n      )\n   \n   [response] =\u003e Array\n      (\n         [data] =\u003e Array\n            (\n               [lastUpdateId] =\u003e 37910427874\n               [bids] =\u003e Array\n                  (\n                     [0] =\u003e Array\n                        (\n                           [price] =\u003e 30319.99000000\n                           [amount] =\u003e 3.58155000\n                        )\n                  \n                     [1] =\u003e Array\n                        (\n                           [price] =\u003e 30319.98000000\n                           [amount] =\u003e 0.09091000\n                        )\n                  )\n               [asks] =\u003e Array\n                  (\n                     [0] =\u003e Array\n                        (\n                           [price] =\u003e 30320.00000000\n                           [amount] =\u003e 21.24342000\n                        )\n                     \n                     [1] =\u003e Array\n                        (\n                           [price] =\u003e 30320.05000000\n                           [amount] =\u003e 0.00170000\n                        )\n                  )\n            )\n         \n         [info] =\u003e Array\n            (\n               [statusCode] =\u003e 200\n               [reasonPhrase] =\u003e OK\n               [headers] =\u003e Array\n                  (\n                     [Content-Type] =\u003e Array\n                        (\n                           [0] =\u003e application/json;charset=UTF-8\n                        )\n                     \n                     ...\n                     \n                     [x-mbx-uuid] =\u003e Array\n                        (\n                           [0] =\u003e ad6df6c5-903b-451b-904c-5ba90eb4576d\n                        )\n                     \n                     [x-mbx-used-weight] =\u003e Array\n                        (\n                           [0] =\u003e 1\n                        )\n                     \n                     [x-mbx-used-weight-1m] =\u003e Array\n                        (\n                           [0] =\u003e 1\n                        )\n                     \n                     ...\n                  )\n            )\n      )\n)\n```\n\u003c/details\u003e\n\n## If you want to use [testnet](https://testnet.binance.vision/)\n```php\n$binanceTestNet = new \\BinanceApi\\Binance(TestNet::BASE_ENDPOINT);\n\n$fullResult = $binance-\u003edepth('BTCUSDT', 2);\n```\n\n## Set api keys\n\nSome endpoints will require an API Keys. You can set them like this:\n\n```php\n$binance-\u003esetApiKeys($apiKey, $secretKey);\n```\n\n## Handle often throws errors:\n```php\ntry {\n    $result = $binance-\u003edepth('BTCUSDT', 2);\n} catch (BinanceApi\\Exception\\BinanceResponseException $e) {\n    // This is exception throw, when binance return error message\n    // https://binance-docs.github.io/apidocs/spot/en/#error-codes\n} catch (\\GuzzleHttp\\Exception\\GuzzleException $e) {\n    // It's about Guzzle exception\n    // https://docs.guzzlephp.org/en/stable/quickstart.html#exceptions\n}\n```\n_Full list of errors, you can see in Basic topic_\n\n## Rate limits\n\nLimits by IP\n\n```php\n$binance-\u003egetAdditional()['limits']['IP']['api'];\n```\n\n```text\nArray\n(\n    [used] =\u003e 2 // By default maximum weight in minute is 1200\n    [lastRequest] =\u003e Sat, 15 Jul 2023 14:19:01 GMT\n)\n```\n\n```php\n$dateTime = new DateTime($binance-\u003egetAdditional()['limits']['IP']['api']['lastRequest']);\n\n$dateTime = new DateTime($binance-\u003egetAdditional()['limits']['IP']['sapi']['lastRequest']);\n```\n\nYou know how much weight you use\n\nBinance reset weights by IP (api and sapi) every minute\n\n## Binance time\n\nAt any places where you need to use time, use a binance microtime format\n\nYou can get binance microtime now by function:\n\n```php\n\\BinanceApi\\Docs\\GeneralInfo\\Signed::binanceMicrotime(); //1690113560956\n```\n\n## More examples\n\nCommon part for all next examples\n\n```php\n$binance = new \\BinanceApi\\Binance();\n\n$binance-\u003esetApiKeys($apiKey, $secretKey);\n\n// Filter every output. Read more about it in a Basic topic or just use it if you need only a body result from request\n$binance-\u003esetOutputCallback(function ($output) {\n    return $output['response']['data'];\n});\n```\n\n### Exchange info\n\nCurrent exchange trading rules and symbol information\n\n```php\n$binance-\u003eexchangeInfo();\n```\n\n### Order book\n\nAll three methods are identical. Use that you prefer\n\n```php\n$binance-\u003edepth('BTCUSDT', 5);\n\n$binance-\u003eorderbook('BTCUSDT', 5);\n\n$binance-\u003eorderbookBTCUSDT(5); // \"BTCUSDT\" you can replace with any market: \"ETHUSDT\", \"BTCBUSD\", ...\n```\n\n### Trades\n\nAll two methods are identical. Use that you prefer\n\n```php\n$binance-\u003etrades('BTCUSDT', 5);\n\n$binance-\u003etradesETHUSDT(5); // \"ETHUSDT\" you can replace with any market: \"BTCUSDT\", \"BTCBUSD\", ...\n```\n\n### Klines/Candlestick\n\nKline/candlestick bars for a symbol.\n\n```php\n$binance-\u003eklines('BTCUSDT', '1m', limit: 50);\n\n$startTime = (new DateTime('01 Jan 2022 00:00:00 GMT'))-\u003egetTimestamp() * 1000;\n$binance-\u003eklines('BTCUSDT', '1d', $startTime);\n\n$endTime = (new DateTime('01 Jan 2023 00:00:00 GMT'))-\u003egetTimestamp() * 1000;\n$binance-\u003eklines('BTCUSDT', '1d', endTime: $endTime);\n```\n```php\n$binance-\u003esecondKlines('BTCUSDT');\n\n$binance-\u003eminuteKlines('BTCUSDT');\n\n$binance-\u003ethreeMinuteKlines('BTCUSDT');\n\n$binance-\u003efiveMinuteKlines('BTCUSDT');\n\n$binance-\u003efifteenMinuteKlines('BTCUSDT');\n\n$binance-\u003ethirtyMinuteKlines('BTCUSDT');\n\n$binance-\u003ehourKlines('BTCUSDT');\n\n$binance-\u003etwoHourKlines('BTCUSDT');\n\n$binance-\u003efourHourKlines('BTCUSDT');\n\n$binance-\u003esixHourKlines('BTCUSDT');\n\n$binance-\u003eeightHourKlines('BTCUSDT');\n\n$binance-\u003etwelveHourKlines('BTCUSDT');\n\n$binance-\u003edayKlines('BTCUSDT');\n\n$binance-\u003ethreeDayKlines('BTCUSDT');\n\n$binance-\u003eweekKlines('BTCUSDT');\n\n$binance-\u003emonthKlines('BTCUSDT');\n```\n```php\n$startTime = new DateTime('01 Jan 2022 00:00:00 GMT');\n$binance-\u003ehourKlines('BTCUSDT', $startTime, limit: 24);\n\n$endTime = new DateTime('01 Jan 2022 00:00:00 GMT');\n$binance-\u003ehourKlines('BTCUSDT', endTime: $endTime, limit: 48);\n```\n\n### Prices\n\nLatest price for a symbol or symbols.\n\n```php\n$binance-\u003etickerPrice();\n\n$binance-\u003etickerPrice('BTCUSDT');\n```\n\n### Limit order\n\n```php\n$binance-\u003eorder('BTCUSDT', 'BUY', 'LIMIT', 'GTC', 0.01, price: 20000);\n\n$binance-\u003elimitOrder('BTCUSDT', 'BUY', 0.01, price: 21000);\n```\n\n### Market order\n\n```php\n$binance-\u003eorder('BTCUSDT', 'BUY', 'MARKET', quantity: 0.01);\n\n$binance-\u003emarketOrder('BTCUSDT', 'SELL', 0.01);\n```\n\n### Stop loss order\n\n```php\n$binance-\u003eorder('BTCUSDT', 'SELL', 'STOP_LOSS', 'GTC', 0.01, stopPrice: 25000);\n\n$binance-\u003estopLossOrder('BTCUSDT', 'SELL', 0.01, stopPrice: 25000);\n```\n\n### Take profit order\n\n```php\n$binance-\u003eorder('BTCUSDT', 'SELL', 'TAKE_PROFIT', 'GTC', 0.01, stopPrice: 100000);\n\n$binance-\u003etakeProfitOrder('BTCUSDT', 'SELL', 0.01, stopPrice: 100000);\n```\n\n### Get open orders\n\nGet all open orders on a symbol. Careful when accessing this with no symbol.\n\n```php\n$binance-\u003eopenOrders('BTCUSDT');\n\n$binance-\u003eopenOrders();\n```\n\n### Get order status\n\nCheck an order's status.\n\n```php\n$binance-\u003egetOrder('BTCUSDT', 8403075);\n```\n\n### Cancel order\n\nCancel an active order.\n\n```php\n$binance-\u003ecancelOrder('BTCUSDT', 8403075);\n```\n\n### Cancel all orders\n\nCancels all active orders on a symbol.\n\n```php\n$binance-\u003ecancelOpenOrders('BTCUSDT');\n```\n\n### Account Information (Including Balances)\n\nGet current account information.\n\n```php\n$binance-\u003eaccount();\n```\n\n### Account Trade List\n\nGet trades for a specific account and symbol.\n\n```php\n$binance-\u003emyTrades('BTCUSDT');\n```\n\n### All Coins' Information\n\nGet information of coins (available for deposit and withdraw) for user.\n\n```php\n$binance-\u003ecapitalConfigGetall();\n```\n\n### Withdraw\n\nSubmit a withdraw request.\n\n```php\n$binance-\u003ecapitalWithdrawApply('USDT', network: 'TRX', address: 'TNGjavWm7sMjCA4r1YhsEYGfaZtZEkXzNf', amount: 10);\n\n$binance-\u003ewithdraw('USDT', network: 'TRX', address: 'TNGjavWm7sMjCA4r1YhsEYGfaZtZEkXzNf', amount: 10);\n```\n\n### Withdraw History (supporting network)\n\nFetch withdraw history.\n\n```php\n$binance-\u003ecapitalWithdrawHistory();\n```\n\n### Deposit Address (supporting network)\n\nFetch deposit address with network.\n\n```php\n$binance-\u003ecapitalDepositAddress('USDT', 'TRX');\n```\n\n### Deposit History (supporting network)\n\nFetch deposit history.\n\n```php\n$binance-\u003ecapitalDepositHisrec();\n```\n\n# Contributing\n- Please give a star or fork repository 💫\n- Create a new issues or pull requests 🤝\n\n# License\n\nBinance PHP API Client is licensed under [The MIT License (MIT)](https://github.com/kleninmaxim/binance-api/blob/1.x/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkleninmaxim%2Fbinance-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkleninmaxim%2Fbinance-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkleninmaxim%2Fbinance-api/lists"}