php-binance-api.php
public function candlesticks(string $symbol, string $interval = "5m", int $limit = null, $startTime = null, $endTime = null)
    {
        if (!isset($this->charts[$symbol])) {
            $this->charts[$symbol] = [];
        }

        $opt = [
            "symbol" => $symbol,
            "interval" => $interval,
        ];

        if ($limit) {
            $opt["limit"] = $limit;
        }

        if ($startTime) {
            $opt["startTime"] = $startTime;
        }

        if ($endTime) {
            $opt["endTime"] = $endTime;
        }

        $response = $this->httpRequest("v1/klines", "GET", $opt);

        if (is_array($response) === false) {
            return [];
        }

        if (count($response) === 0) {
            echo "warning: v1/klines returned empty array, usually a blip in the connection or server" . PHP_EOL;
            return [];
        }

        $ticks = $this->chartData($symbol, $interval, $response);
        $this->charts[$symbol][$interval] = $ticks;
        return $ticks;
    }
public function candlesticks(string $symbol, string $interval = "5m", int $limit = null, $startTime = null, $endTime = null)
    {
        if (!isset($this->charts[$symbol])) {
            $this->charts[$symbol] = [];
        }

        $opt = [
            "symbol" => $symbol,
            "interval" => $interval,
        ];

        if ($limit) {
            $opt["limit"] = $limit;
        }

        if ($startTime) {
            $opt["startTime"] = $startTime;
        }

        if ($endTime) {
            $opt["endTime"] = $endTime;
        }

        $response = $this->httpRequest("v1/klines", "GET", $opt);

        if (is_array($response) === false) {
            return [];
        }

        if (count($response) === 0) {
            echo "warning: v1/klines returned empty array, usually a blip in the connection or server" . PHP_EOL;
            return [];
        }

        $ticks = $this->chartData($symbol, $interval, $response);
        $this->charts[$symbol][$interval] = $ticks;
        return $ticks;
    }
public function candlesticks ( string $ symbol , string $ interval = "5m" , int $ limit = null , $ startTime = null , $ endTime = null ) { if ( ! isset ( $ this -> charts [ $ symbol ] ) ) { $ this -> charts [ $ symbol ] = [ ] ; } $ opt = [ "symbol" => $ symbol , "interval" => $ interval , ] ; if ( $ limit ) { $ opt [ "limit" ] = $ limit ; } if ( $ startTime ) { $ opt [ "startTime" ] = $ startTime ; } if ( $ endTime ) { $ opt [ "endTime" ] = $ endTime ; } $ response = $ this -> httpRequest ( "v1/klines" , "GET" , $ opt ) ; if ( is_array ( $ response ) === false ) { return [ ] ; } if ( count ( $ response ) === 0 ) { echo "warning: v1/klines returned empty array, usually a blip in the connection or server" . PHP_EOL ; return [ ] ; } $ ticks = $ this -> chartData ( $ symbol , $ interval , $ response ) ; $ this -> charts [ $ symbol ] [ $ interval ] = $ ticks ; return $ ticks ; }
candlesticks get the candles for the given intervals
1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M

$candles = $api->candlesticks("BNBBTC", "5m");

@param $symbol string to query
@param $interval string to request
@param $limit int limit the amount of candles
@param $startTime string request candle information starting from here
@param $endTime string request candle information ending here
@return array containing the response
@throws \Exception
candlesticks get the candles for the given intervals 1m 3m 5m 15m 30m 1h 2h 4h 6h 8h 12h 1d 3d 1w 1M