Overview

Namespaces

  • Larislackers
    • BinanceApi
      • Enums
      • Exception

Classes

  • BinanceApiContainer
  • Overview
  • Namespace
  • Class

Class BinanceApiContainer

Wrapper container for Binance API.

Namespace: Larislackers\BinanceApi
Package: Larislackers\BinanceApi
Located at BinanceApiContainer.php
Methods summary
public
# __construct( string $apiKey, string $apiSecret )

BinanceApiContainer constructor.

BinanceApiContainer constructor.

Parameters

$apiKey
The API key from Binance.
$apiSecret
The API secret from Binance.
public string
# getApiKey( )

Gets the API key.

Gets the API key.

Returns

string
public string
# getApiSecret( )

Gets the API secret.

Gets the API secret.

Returns

string
public Psr\Http\Message\ResponseInterface
# ping( )

Test connectivity to the Rest API.

Test connectivity to the Rest API.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#test-connectivity
public Psr\Http\Message\ResponseInterface
# getServerTime( )

Test connectivity to the Rest API and get the current server time.

Test connectivity to the Rest API and get the current server time.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#check-server-time
public Psr\Http\Message\ResponseInterface
# getOrderBook( array $params )

Returns the order book for the market.

Returns the order book for the market.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#order-book

Option

string "symbol" The symbol to search for. (required)
int "limit" The number of results returned from the query. (max value 100)
public Psr\Http\Message\ResponseInterface
# getAggTrades( array $params )

Returns compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.

Returns compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Throws

Exception

Link

https://www.binance.com/restapipub.html#compressedaggregate-trades-list

Option

string "symbol" The symbol to search for. (required)
int "fromId" ID to get aggregate trades from INCLUSIVE.
int "startTime" Timestamp in milliseconds to get aggregate trades from INCLUSIVE.
int "endTime" Timestamp in milliseconds to get aggregate trades until INCLUSIVE.
int "limit" The number of results returned from the query. (max value 500)
public Psr\Http\Message\ResponseInterface
# getKlines( array $params )

Returns kline/candlesticks bars for a symbol. Klines are uniquely identified by their open time.

Returns kline/candlesticks bars for a symbol. Klines are uniquely identified by their open time.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#klinecandlesticks

Option

string "symbol" The symbol to search for. (required)
string "interval" Kline intervals enum. (required)
int "startTime" Timestamp in milliseconds to get aggregate trades from INCLUSIVE.
int "endTime" Timestamp in milliseconds to get aggregate trades until INCLUSIVE.
int "limit" The number of results returned from the query. (max value 500)
public Psr\Http\Message\ResponseInterface
# getTwentyFourTickerPrice( array $params )

Returns 24 hour price change statistics.

Returns 24 hour price change statistics.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#24hr-ticker-price-change-statistics

Option

string "symbol" The symbol to search for. (required)
public Psr\Http\Message\ResponseInterface
# getTickers( )

Returns latest price for all symbols.

Returns latest price for all symbols.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#symbols-price-ticker
public Psr\Http\Message\ResponseInterface
# getBookTickers( )

Returns price/qty on the order book for all symbols.

Returns price/qty on the order book for all symbols.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#symbols-order-book-ticker
public Psr\Http\Message\ResponseInterface
# postOrder( array $params )

Send in a new order.

Send in a new order.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#new-order--signed

Option

string "symbol" The symbol to search for. (required)
string "side" Order side enum. (required)
string "type" Order type enum. (required)
string "timeInForce" Time in force enum. (required)
double "quantity" Desired quantity. (required)
double "price" Asking price. (required)
string "newClientOrderId" A unique id for the order. Automatically generated by default.
double "stopPrice" Used with STOP orders.
double "icebergQty" Used with icebergOrders.
int "timestamp" A UNIX timestamp. (required)
public Psr\Http\Message\ResponseInterface
# postOrderTest( array $params )

Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.

Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#test-new-order-signed

Option

string "symbol" The symbol to search for. (required)
string "side" Order side enum. (required)
string "type" Order type enum. (required)
string "timeInForce" Time in force enum. (required)
double "quantity" Desired quantity. (required)
double "price" Asking price. (required)
string "newClientOrderId" A unique id for the order. Automatically generated by default.
double "stopPrice" Used with STOP orders.
double "icebergQty" Used with icebergOrders.
int "timestamp" A UNIX timestamp. (required)
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
public Psr\Http\Message\ResponseInterface
# getOrder( array $params )

Check an order's status.

Check an order's status.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Throws

Exception

Link

https://www.binance.com/restapipub.html#query-order-signed

Option

string "symbol" The symbol to search for. (required)
int "orderId" The order ID.
string "origClientOrderId" The original client order ID.
int "timestamp" A UNIX timestamp. (required)
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
public Psr\Http\Message\ResponseInterface
# cancelOrder( array $params )

Cancel an active order.

Cancel an active order.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Throws

Exception

Link

https://www.binance.com/restapipub.html#cancel-order-signed

Option

string "symbol" The symbol to search for. (required)
int "orderId" The order ID.
string "origClientOrderId" The original client order ID.
string "newClientOrderId" Used to uniquely identify this cancel. Automatically generated by default.
int "timestamp" A UNIX timestamp. (required)
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
public Psr\Http\Message\ResponseInterface
# getOpenOrders( array $params )

Returns all open orders on a symbol.

Returns all open orders on a symbol.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#current-open-orders-signed

Option

string "symbol" The symbol to search for. (required)
int "timestamp" A UNIX timestamp. (required)
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
public Psr\Http\Message\ResponseInterface
# getOrders( array $params )

Returns all account orders; active, canceled, or filled.

Returns all account orders; active, canceled, or filled.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#all-orders-signed

Option

string "symbol" The symbol to search for. (required)
int "orderId" The order ID.
int "timestamp" A UNIX timestamp. (required)
int "limit" The request limit, max value 500, min value 1.
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
public Psr\Http\Message\ResponseInterface
# getAccount( array $params )

Returns current account information.

Returns current account information.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#account-information-signed

Option

int "timestamp" A UNIX timestamp. (required)
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
public Psr\Http\Message\ResponseInterface
# getTrades( array $params )

Returns trades for a specific account and symbol.

Returns trades for a specific account and symbol.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#account-trade-list-signed

Option

string "symbol" The symbol to search for. (required)
int "fromId" The order ID.
int "timestamp" A UNIX timestamp. (required)
int "limit" The number of results returned from the query. (max value 500)
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
public Psr\Http\Message\ResponseInterface
# withdraw( array $params )

Submit a withdraw request.

Submit a withdraw request.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#account-trade-list-signed

Option

string "asset" The requested asset. (required)
string "address" The request address. (required)
double "amount" The request amount. (required)
string "name" Description of the address.
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
int "timestamp" A UNIX timestamp. (required)
public Psr\Http\Message\ResponseInterface
# getDepositHistory( array $params )

Fetch deposit history.

Fetch deposit history.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#account-trade-list-signed

Option

string "asset" The requested asset.
enum "status" Enum as WAPI_DEPOSIT_STATUS_*.
int "startTime" Timestamp in milliseconds.
int "endTime" Timestamp in milliseconds.
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
int "timestamp" A UNIX timestamp. (required)
public Psr\Http\Message\ResponseInterface
# getWithdrawHistory( array $params )

Fetch withdraw history.

Fetch withdraw history.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#account-trade-list-signed

Option

string "asset" The requested asset.
enum "status" Enum as WAPI_WITHDRAW_STATUS_*.
int "startTime" Timestamp in milliseconds.
int "endTime" Timestamp in milliseconds.
int "recvWindow" The number of milliseconds after timestamp the request is valid for.
int "timestamp" A UNIX timestamp. (required)
public Psr\Http\Message\ResponseInterface
# startUserDataStream( )

Start a new user data stream.

Start a new user data stream.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#start-user-data-stream-api-key
public Psr\Http\Message\ResponseInterface
# keepaliveUserDataStream( array $params )

PING a user data stream to prevent a time out.

PING a user data stream to prevent a time out.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#keepalive-user-data-stream-api-key

Option

string "listenKey" The key for the user's data steam. (required)
public Psr\Http\Message\ResponseInterface
# closeUserDataStream( array $params )

Close out a user data stream.

Close out a user data stream.

Parameters

$params
The data to send.

Returns

Psr\Http\Message\ResponseInterface

Link

https://www.binance.com/restapipub.html#close-user-data-stream-api-key

Option

string "listenKey" The key for the user's data steam. (required)
public
# depthWebsocket( array $params )

Websocket url for depth endpoint.

Websocket url for depth endpoint.

Parameters

$params
The data to send.

Link

https://www.binance.com/restapipub.html#depth-wss-endpoint

Option

string "symbol" The symbol to search for. (required)
public
# klineWebsocket( array $params )

Websocket url for kline endpoint.

Websocket url for kline endpoint.

Parameters

$params
The data to send.

Link

https://www.binance.com/restapipub.html#kline-wss-endpoint

Option

string "symbol" The symbol to search for. (required)
string "interval" Kline intervals enum. (required)
public
# tradesWebsocket( array $params )

Websocket url for trades endpoint.

Websocket url for trades endpoint.

Parameters

$params
The data to send.

Link

https://www.binance.com/restapipub.html#trades-wss-endpoint

Option

string "symbol" The symbol to search for. (required)
public
# userWebsocket( array $params )

Websocket url for user data endpoint.

Websocket url for user data endpoint.

Parameters

$params
The data to send.

Link

https://www.binance.com/restapipub.html#user-wss-endpoint

Option

string "listenKey" The key for the user's data steam. (required)
API documentation generated by ApiGen