Skip to content

Commit 530c217

Browse files
committed
orderRateLimit added
1 parent fb52096 commit 530c217

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

php-binance-api.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,6 +3514,26 @@ public function apiTradingStatus(array $params = [])
35143514
return $arr;
35153515
}
35163516

3517+
/**
3518+
* orderRateLimit gets the user rate limit
3519+
*
3520+
* @link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-unfilled-order-count-user_data
3521+
*
3522+
* $rateLimit = $api->orderRateLimit();
3523+
*
3524+
* @property int $weight 1
3525+
*
3526+
* @param array $params (optional) An array of additional parameters that the API endpoint allows
3527+
* - @param int $params['recvWindow'] (optional) the time in milliseconds to wait for the response
3528+
*
3529+
* @return array with error message or the rate limit details
3530+
* @throws \Exception
3531+
*/
3532+
public function orderRateLimit(array $params = [])
3533+
{
3534+
return $this->apiRequest("v3/rateLimit/order", 'GET', $params, true);
3535+
}
3536+
35173537
/**
35183538
* ocoOrder - Create a new OCO order
35193539
*

tests/BinanceLiveTests.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,22 @@ public function testOrderRateLimitFutures()
13881388
$this->assertIsInt($firstEntry['limit']);
13891389
}
13901390

1391+
public function testOrderRateLimit()
1392+
{
1393+
$res = $this->spotBinance->orderRateLimit();
1394+
$this->assertIsArray($res);
1395+
$firstEntry = $res[0];
1396+
$this->assertIsArray($firstEntry);
1397+
$this->assertArrayHasKey('rateLimitType', $firstEntry);
1398+
$this->assertEquals('ORDERS', $firstEntry['rateLimitType']);
1399+
$this->assertArrayHasKey('interval', $firstEntry);
1400+
$this->assertIsString($firstEntry['interval']);
1401+
$this->assertArrayHasKey('intervalNum', $firstEntry);
1402+
$this->assertIsNumeric($firstEntry['intervalNum']);
1403+
$this->assertArrayHasKey('limit', $firstEntry);
1404+
$this->assertIsInt($firstEntry['limit']);
1405+
}
1406+
13911407
public function testLeveragesFutures()
13921408
{
13931409
$res = $this->futuresBinance->futuresLeverages($this->symbol);

tests/BinanceStaticTests.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,6 +2711,23 @@ public function testFuturesOrderRateLimit()
27112711
$this->assertEquals($this->recvWindow, $params['recvWindow']);
27122712
}
27132713

2714+
public function testOrderRateLimit()
2715+
{
2716+
try {
2717+
$this->binance->orderRateLimit([ 'recvWindow' => $this->recvWindow ]);
2718+
2719+
} catch (\Throwable $e) {
2720+
2721+
}
2722+
$endpoint = "https://api.binance.com/api/v3/rateLimit/order?";
2723+
$this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint));
2724+
2725+
$queryString = substr(self::$capturedUrl, strlen($endpoint));
2726+
parse_str($queryString, $params);
2727+
2728+
$this->assertEquals($this->recvWindow, $params['recvWindow']);
2729+
}
2730+
27142731
public function testFuturesLeverages()
27152732
{
27162733
try {

0 commit comments

Comments
 (0)