A Laravel Wrapper for the Binance API. Now easily connect and consume the Binance Public & Private API in your Laravel apps without any hassle.

Overview

GitHub release GitHub issues Software License Total Downloads

This package provides a Laravel Wrapper for the Binance API and allows you to easily communicate with it.


Important Note

This package is in early development stage. It is not advisable to use it in a production app until v1.0 is released. Feel free to open a PR to contribute to this project and help me reach a production ready build.


Installation

You can install the package via composer:

composer require techtailor/laravel-binance-api

You can publish the config file with:

php artisan vendor:publish --tag="binance-api-config"

Open your .env file and add the following (replace YOUR_API_KEY and YOUR_SECRET with the API Key & Secret you received from Binance) -

BINANCE_KEY=YOUR_API_KEY
BINANCE_SECRET=YOUR_SECRET

Or

Open the published config file available at config/binance-api.php and add your API and Secret Keys:

return [
    'auth' => [
        'key'        => env('BINANCE_KEY', 'YOUR_API_KEY'),
        'secret'     => env('BINANCE_SECRET', 'YOUR_SECRET')
    ],
];

Usage

Using this package is very simple. Just initialize the Api and call one of the available methods:

use TechTailor\BinanceApi\BinanceAPI;

$binance = new BinanceAPI();

$time = $binance->getTime();

You can also set an API & Secret for a user by passing it after initalization (useful when you need to isolate api keys for individual users):

$binance = new BinanceApi();

$binance->setApi($apiKey, $secretKey);

$accountInfo = $binance->getAccountInfo();

Available Methods

Available Public Methods (Security Type : NONE) [API Keys Not Required]

- getSystemStatus()         // returns system status, expect msg to be "normal".
- getTime()                 // returns server timestamp.
- getExchangeInfo($symbol)  // returns current exchange trading rules and symbol information.
- getOrderBook($symbol)     // returns the order book for the symbol.
- getAvgPrice($symbol)      // returns the average price for a symbol.
- getTicker($symbol)        // returns the 24hr ticker for a symbol (if no symbol provided, returns an array of all symbols).

Available Private Methods (Security Type : USER_DATA) [API Keys Required]

- getAccountInfo()          // returns current account information.
- getAllOrders()            // return all current account orders (active, canceled or filled).
- getOpenOrders($symbol)    // returns all current account open orders (Careful when accessing without symbol).
- getTrades($symbol)        // returns all trades for a symbol.
- getOrderStatus($symbol, $orderId) // returns status of a given order.
- getUserCoinsInfo()        // returns information of all coins available to the user.
- getDepositHistory()       // returns the user's deposit history.
- getWithdrawHistory()      // returns the user's withdraw history.

TODO

List of features or additional functionality we are working on (in no particular order) -

- Improve exception handling.
- Add rate limiting to API Calls.
- Add response for API ban/blacklisting response.
- Improve ReadMe.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Use Ray in any PHP script without requiring it in your projects.

Global Ray Use Ray in any PHP script without requiring it in your projects. Require this package globally with Composer: composer global require cuyz/

This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

EasyRdf is a PHP library designed to make it easy to consume and produce RDF.

EasyRdf EasyRdf is a PHP library designed to make it easy to consume and produce RDF. It was designed for use in mixed teams of experienced and inexpe

Laravel & MySQL, jQuery, Ajax, Bootstrap. Also, it's include email send function without any API.
Laravel & MySQL, jQuery, Ajax, Bootstrap. Also, it's include email send function without any API.

Rewards-Dacor Laravel & MySQL, jQuery, Ajax, Bootstrap. Also, it's include email send function without any API. [Live site link] ( https://rewardsdaco

 A Symfony bundle built to schedule/consume repetitive tasks
A Symfony bundle built to schedule/consume repetitive tasks

Daily runs Code style Infection PHPUnit Rector Security Static analysis A Symfony bundle built to schedule/consume repetitive tasks Main features Exte

Fly50W is a new language which helps you build simple apps using more than 500k lines of code easily.

Fly50W is a new language which helps you build simple apps using more than 500k lines of code easily. Installation

A now playing screen for the Raspberry Pi using the Last.fm API.
A now playing screen for the Raspberry Pi using the Last.fm API.

raspberry-pi-now-playing A now playing screen for the Raspberry Pi using the Last.fm API. This project is detailed, with photos of how I used it with

Your private self hosted composer repository with user management

Devliver Your private self-hosted composer repository. Requirements Docker MariaDB/MySQL the running docker container has access to private git reposi

BTCUSDT Binance Otomatik Al-Sat yazılımı, RSI indikatörüne göre.
BTCUSDT Binance Otomatik Al-Sat yazılımı, RSI indikatörüne göre.

Robin Hood Binance Otomatik Al-Sat yapan yardımcı yazılımdır. Kurulum: git clone https://github.com/burakerenel/robinhood cd robinhood && composer ins

Comments
  • New Order

    New Order

    Hello I need to create new order function with your class. I tried that but its not work for me

    ` /** * Create a new order. * * @throws Exception * * @param string $symbol Exchange Pair Symbol * @param string $side Order side (BUY or SELL) * @param string $type Order type (LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER) * @param string $timeInForce (GTC, IOC) * @param float $quantity Order quantity * @param float $price Order price * @param float $stopPrice (for STOP_LOSS and TAKE_PROFIT orders) * @param float $icebergQty (for LIMIT orders) * @param float $newOrderResprice (for STOP_LOSS and TAKE_PROFIT orders) * @param float $newOrderResptime (for STOP_LOSS and TAKE_PROFIT orders) * @param string $recvWindow (optional) * @param string $timing (optional) * * @return mixed */ // public function createOrder($symbol, $side, $type, $timeInForce, $quantity, $price, $stopPrice = null, $icebergQty = null, $newOrderResprice = null, $newOrderResptime = null, $recvWindow = null, $timing = null) public function createOrder() { $data = [ // 'symbol' => $symbol ? strtoupper($symbol) : null, // 'side' => $side ? strtoupper($side) : null, // 'type' => $type ? strtoupper($type) : null, // 'timeInForce' => $timeInForce ? strtoupper($timeInForce) : null, // 'quantity' => $quantity ? $quantity : null, // 'price' => $price ? $price : null, // 'stopPrice' => $stopPrice ? $stopPrice : null, // 'icebergQty' => $icebergQty ? $icebergQty : null, // 'newOrderResprice' => $newOrderResprice ? $newOrderResprice : null, // 'newOrderResptime' => $newOrderResptime ? $newOrderResptime : null, // 'recvWindow' => $recvWindow ? $recvWindow : $this->recvWindow, // 'timestamp' => $this->milliseconds(),

              'symbol' => 'BNBUSDT',
              'side' => 'BUY',
              'type' => 'LIMIT',
              'timeInForce' => 'GTC',
              'quantity' => "1",
              'price' => "41",
          ];
    
          $response = $this->privateRequest('v3/order', $data, 'POST');
    
          return $response;
      }
    

    error is : array:3 [▼ "code" => "-1104" "error" => "INVALID_REQUEST" "message" => "Not all sent parameters were read; read 1 parameter(s) but was sent 2." ] ` Can you help me about it?

    opened by Mert-coderoid 0
Releases(0.1.0)
Owner
Moinuddin S. Khaja
Developer @Spargon
Moinuddin S. Khaja
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion.

Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion. HTTP API, HTTPs support, webhook handler, scheduled builds, Slack and HipChat integration.

Łukasz Lach 112 Nov 24, 2022
Private Composer registry for private PHP packages on AWS Serverless

Tug Tug is a Composer private registry for private PHP packages installable with Composer (1 and 2). The main idea of this project is to have an inter

Fxp 33 Oct 5, 2022
Initiated by me, enhanced by us, created for us. This is the fork (public) version separated from my private diary repository.

diary public repository Initiated by me, enhanced by us, created for us. This is the fork (public) version separated from my private diary repository.

Weicheng Ao 3 Jul 30, 2022
EBook-Apps - The eBook Apps is a web application that helps you browse ebooks from anywhere using your smartphone and laptop.

⚡️ eBook Apps The eBook Apps is a web application that helps you browse ebooks from anywhere using your smartphone and laptop. ?? Getting Started To s

Ahmad Fauzy 32 Nov 14, 2022
Here is an Instagram Guest API. Gather all public information as JSON format without logging yourself.

Here is an Instagram Guest API. Gather all public information as JSON format without logging yourself. It's all automation and time saving.

Quatrecentquatre 1 Nov 2, 2021
Medical Master or "Medic-M" was built to reduce the hassle of buying medicine, provide medicine to the sick in a short time. It is an HTML, CSS, JAVASCRIPT and PHP based system.

Medical Master (Medic-M) | WELCOME TO Medic-M(MEDICAL MASTER) | | Introduction | Medical Master or "Medic-M" was built to reduce the hassle of buying

NILOY KANTI PAUL 5 Oct 8, 2022
Track your farming and pool performance on the Binance Smart Chain

farm.army - Frontend Track your farming and pool performance on the Binance Smart Chain. Tech Stack PHP 8 + Symfony node.js + npm (Webpack, Symfony en

farm.army 28 Sep 3, 2022
Quickly and easily preview and test your Magento 2 order confirmation page, without hacks or spending time placing new order each time

Preview Order Confirmation Page for Magento 2 For Magento 2.0.x, 2.1.x, 2.2.x and 2.3.x Styling and testing Magento's order confirmation page can be a

MagePal :: Magento Extensions 71 Aug 12, 2022
A PHP 7.4+ library to consume the Confluent Schema Registry REST API

A PHP 7.4+ library to consume the Confluent Schema Registry REST API. It provides low level functions to create PSR-7 compliant requests that can be used as well as high level abstractions to ease developer experience.

Flix.TECH 38 Sep 1, 2022