📜  larevel binance api - PHP (1)

📅  最后修改于: 2023-12-03 15:32:37.505000             🧑  作者: Mango

Laravel Binance API - PHP

The Laravel Binance API is a package that allows developers to easily access the Binance API using PHP. This package provides a simple and easy-to-use interface for working with the Binance API, allowing developers to focus on building their applications instead of worrying about the complexities of the API.

Getting Started

To get started with the Laravel Binance API package, you will first need to install it. You can do this using Composer by running the following command:

composer require adman9000/laravel-binance-api

Once the package is installed, you can start using it by creating an instance of the BinanceAPI class. You can do this by injecting the BinanceAPI class into your code:

use adman9000\laravel_binance_api\BinanceAPI;

class MyController extends Controller
{
    public function myMethod(BinanceAPI $binance) 
    {
        // Your code here
    }
}

Alternatively, you can create an instance of the BinanceAPI class manually:

use adman9000\laravel_binance_api\BinanceAPI;

$apiKey = 'your_api_key';
$apiSecret = 'your_api_secret';

$binance = new BinanceAPI($apiKey, $apiSecret);
The API Interface

The Laravel Binance API package provides a simple interface for working with the Binance API. The following methods are available:

getAccountInfo()

Get account information for the current user.

$accountInfo = $binance->getAccountInfo();
getOrderBook($symbol, $limit = 100)

Get the order book for a given symbol.

$symbol = 'BTCUSDT';
$limit = 20;

$orderBook = $binance->getOrderBook($symbol, $limit);
getKlines($symbol, $interval, $limit = 500)

Get klines (candlestick) data for a given symbol.

$symbol = 'BTCUSDT';
$interval = '1h';
$limit = 100;

$klines = $binance->getKlines($symbol, $interval, $limit);
getTrades($symbol)

Get recent trades for a given symbol.

$symbol = 'BTCUSDT';

$trades = $binance->getTrades($symbol);
getTickerPrice($symbol)

Get the ticker price for a given symbol.

$symbol = 'BTCUSDT';

$tickerPrice = $binance->getTickerPrice($symbol);
Conclusion

The Laravel Binance API package provides a simple and easy-to-use interface for working with the Binance API using PHP. With this package, developers can easily build applications that interact with the Binance exchange without having to worry about the complexities of the API.