### Key Pair Authentication Setup Source: https://github.com/binance/binance-connector-php/blob/master/src/nft/docs/rest-api/key-pair-authentication.md Example of how to initialize the NftRestApi client using key pair authentication. ```APIDOC ## Key Pair Based Authentication This section details how to configure key pair authentication for the Binance API using the provided PHP client. ### Setup To use key pair authentication, you need to provide your API key, the path to your private key file, and optionally a passphrase if your private key is encrypted. ```php use Binance\Client\Spot\Api\NftRestApi; use Binance\Client\Spot\NftRestApiUtil; $configurationBuilder = NftRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('YOUR_API_KEY') ->privateKey('file:///path/to/your/private.key') // Or provide the private key directly as a string ->privateKeyPass('YOUR_PRIVATE_KEY_PASSPHRASE'); // Optional: Required if the private key is encrypted $api = new NftRestApi($configurationBuilder->build()); ``` ### Parameters - **apiKey**: Your Binance API key. - **privateKey**: The path to your private key file or the private key string itself. - **privateKeyPass**: (Optional) The passphrase for your private key if it is encrypted. ``` -------------------------------- ### Get Futures Lead Trading Symbol Whitelist API Example (PHP) Source: https://github.com/binance/binance-connector-php/blob/master/src/copy-trading/docs/Api/FutureCopyTradingApi.md Shows how to fetch the whitelist of symbols available for futures lead trading using the Binance PHP SDK. The SDK must be installed via Composer. ```php getFuturesLeadTradingSymbolWhitelist($recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling FutureCopyTradingApi->getFuturesLeadTradingSymbolWhitelist: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Install Binance PHP Connectors Source: https://github.com/binance/binance-connector-php/blob/master/README.md Install all connectors using Composer. Ensure PHP version is >= 8.4.0. ```bash composer require binance/binance-connector-php ``` -------------------------------- ### Get Collateral Asset Data PHP Example Source: https://github.com/binance/binance-connector-php/blob/master/src/vip-loan/docs/Api/MarketDataApi.md Retrieves data for collateral assets. This method requires the Guzzle HTTP client and proper autoloader setup. ```php getCollateralAssetData($collateralCoin, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling MarketDataApi->getCollateralAssetData: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Old Client Initialization Example Source: https://github.com/binance/binance-connector-php/blob/master/src/rebate/docs/rest-api/migration-guide.md Demonstrates the old method of initializing the Binance Spot client. ```php $client = new Binance Spot([ 'key' => $key, 'privateKey' => $privateKey, # pass the key file directly 'baseURL' => 'https://testnet.binance.vision' ]); ``` -------------------------------- ### Get Borrow Interest Rate PHP Example Source: https://github.com/binance/binance-connector-php/blob/master/src/vip-loan/docs/Api/MarketDataApi.md Fetches the borrow interest rate for specified loan coins. Ensure you have the Guzzle HTTP client installed and the autoloader configured. ```php getBorrowInterestRate($loanCoin, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling MarketDataApi->getBorrowInterestRate: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### New Client Initialization Source: https://github.com/binance/binance-connector-php/blob/master/src/spot/docs/rest-api/migration-guide.md Example of initializing the modularized Spot client using SpotRestApiUtil. ```php $configurationBuilder = SpotRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new SpotRestApi($configurationBuilder->build()); ``` -------------------------------- ### Initialize Spot Client (New) Source: https://github.com/binance/binance-connector-php/blob/master/MIGRATION.md Example of initializing the Spot client using the new modular connector. Uses a configuration builder for API key and private key. ```php $configurationBuilder = SpotRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new SpotRestApi($configurationBuilder->build()); $omitZeroBalances = false; $recvWindow = 5000; $response = $api->getAccount($omitZeroBalances, $recvWindow); print_r($response); ``` -------------------------------- ### Get Futures Lead Trader Status API Example (PHP) Source: https://github.com/binance/binance-connector-php/blob/master/src/copy-trading/docs/Api/FutureCopyTradingApi.md Demonstrates how to retrieve the current futures lead trader status using the Binance PHP SDK. Ensure the SDK is installed via Composer. ```php getFuturesLeadTraderStatus($recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling FutureCopyTradingApi->getFuturesLeadTraderStatus: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Initialize Binance Pay Client (Old) Source: https://github.com/binance/binance-connector-php/blob/master/src/pay/docs/rest-api/migration-guide.md Example of initializing the Binance Spot client with API key and private key. ```php $key = ''; # api key is also required $privateKey = 'file:///path/to/rsa/private/key.pem'; $client = new \\Binance\\Spot([ 'key' => $key, 'privateKey' => $privateKey, # pass the key file directly 'baseURL' => 'https://testnet.binance.vision' ]); ``` -------------------------------- ### Get Position Margin Change History (PHP) Source: https://github.com/binance/binance-connector-php/blob/master/src/derivatives-trading-usds-futures/docs/Api/TradeApi.md Retrieves the history of position margin changes for a given symbol and type. Supports filtering by start time, end time, and limit. Ensure the Guzzle HTTP client is installed. ```php getPositionMarginChangeHistory($symbol, $type, $startTime, $endTime, $limit, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling TradeApi->getPositionMarginChangeHistory: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Initialize Spot Client (Old) Source: https://github.com/binance/binance-connector-php/blob/master/MIGRATION.md Example of initializing the Spot client using the old monolithic connector. Requires API key and private key file. ```php $key = ''; # api key is also required $privateKey = 'file:///path/to/rsa/private/key.pem'; $client = new \Binance\Spot([ 'key' => $key, 'privateKey' => $privateKey, # pass the key file directly 'baseURL' => 'https://testnet.binance.vision' ]); $response = $client->account(); echo json_encode($response); ``` -------------------------------- ### Old Client Initialization Source: https://github.com/binance/binance-connector-php/blob/master/src/algo/docs/rest-api/migration-guide.md Example of initializing the Binance Spot client with API key and private key. ```php $key = ''; # api key is also required $privateKey = 'file:///path/to/rsa/private/key.pem'; $client = new \Binance\Spot([ 'key' => $key, 'privateKey' => $privateKey, # pass the key file directly 'baseURL' => 'https://testnet.binance.vision' ]); ``` -------------------------------- ### Get Pay Trade History Example Source: https://github.com/binance/binance-connector-php/blob/master/src/pay/docs/Api/PayApi.md Demonstrates how to retrieve pay trade history using the `getPayTradeHistory` method. It includes setup for the API client and error handling. The `startTime` and `endTime` parameters are optional; if omitted, data from the last 90 days is returned. The maximum interval between `startTime` and `endTime` is 90 days, and the API supports querying orders within the last 18 months. ```php getPayTradeHistory($startTime, $endTime, $limit, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling PayApi->getPayTradeHistory: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Order Detail Source: https://github.com/binance/binance-connector-php/blob/master/src/fiat/example_rest.md Retrieves the details of a specific fiat order. Refer to the linked example for usage. ```APIDOC ## GET /sapi/v1/fiat/get-order-detail ### Description Retrieves the details of a specific fiat order. ### Method GET ### Endpoint /sapi/v1/fiat/get-order-detail ### Parameters (Details not provided in source, refer to linked documentation for specifics) ### Request Example (Not provided in source) ### Response (Not provided in source) ``` -------------------------------- ### New Client Initialization Source: https://github.com/binance/binance-connector-php/blob/master/src/mining/docs/rest-api/migration-guide.md Example of initializing the client with the new modularized structure. ```php $configurationBuilder = MiningRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new MiningRestApi($configurationBuilder->build()); ``` -------------------------------- ### New Client Initialization Source: https://github.com/binance/binance-connector-php/blob/master/src/algo/docs/rest-api/migration-guide.md Example of initializing the modularized AlgoRestApi client using a configuration builder. ```php $configurationBuilder = AlgoRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new AlgoRestApi($configurationBuilder->build()); ``` -------------------------------- ### Initialize Client: Old Method Source: https://github.com/binance/binance-connector-php/blob/master/src/vip-loan/docs/rest-api/migration-guide.md This shows the old method of initializing the Binance Spot client with API key, private key, and base URL. ```php $key = ''; # api key is also required $privateKey = 'file:///path/to/rsa/private/key.pem' $client = new \\Binance\\Spot([ 'key' => $key, 'privateKey' => $privateKey, # pass the key file directly 'baseURL' => 'https://testnet.binance.vision' ]); ``` -------------------------------- ### Get Fiat Payments History Source: https://github.com/binance/binance-connector-php/blob/master/src/fiat/example_rest.md Retrieves the history of fiat payment transactions. Refer to the linked example for usage. ```APIDOC ## GET /sapi/v1/fiat/payments ### Description Retrieves the history of fiat payment transactions. ### Method GET ### Endpoint /sapi/v1/fiat/payments ### Parameters (Details not provided in source, refer to linked documentation for specifics) ### Request Example (Not provided in source) ### Response (Not provided in source) ``` -------------------------------- ### Initialize Binance Pay Client (New) Source: https://github.com/binance/binance-connector-php/blob/master/src/pay/docs/rest-api/migration-guide.md Example of initializing the modularized Binance PayRestApi client using a configuration builder. ```php $configurationBuilder = PayRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new PayRestApi($configurationBuilder->build()); ``` -------------------------------- ### Get Fiat Deposit/Withdraw History Source: https://github.com/binance/binance-connector-php/blob/master/src/fiat/example_rest.md Retrieves the history of fiat deposit and withdrawal transactions. Refer to the linked example for usage. ```APIDOC ## GET /sapi/v1/fiat/orders ### Description Retrieves the history of fiat deposit and withdrawal transactions. ### Method GET ### Endpoint /sapi/v1/fiat/orders ### Parameters (Details not provided in source, refer to linked documentation for specifics) ### Request Example (Not provided in source) ### Response (Not provided in source) ``` -------------------------------- ### Initialize Dual Investment Client (New) Source: https://github.com/binance/binance-connector-php/blob/master/src/dual-investment/docs/rest-api/migration-guide.md Example of initializing the client with the new modularized structure. ```php $configurationBuilder = DualInvestmentRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new DualInvestmentRestApi($configurationBuilder->build()); ``` -------------------------------- ### getCryptoLoansIncomeHistory Source: https://github.com/binance/binance-connector-php/blob/master/src/crypto-loan/docs/Api/StableRateApi.md Get Crypto Loans Income History. Retrieves historical income data for crypto loans. If start and end times are not provided, recent 7-day data is returned. The maximum interval between start and end times is 30 days. ```APIDOC ## GET /sapi/v1/loan/income ### Description Get Crypto Loans Income History(USER_DATA) Get Crypto Loans Income History * If startTime and endTime are not sent, the recent 7-day data will be returned. * The max interval between startTime and endTime is 30 days. Weight: 6000 ### Method GET ### Endpoint /sapi/v1/loan/income ### Parameters #### Query Parameters - **asset** (string) - Required - - **type** (string) - Optional - All types will be returned by default. Enum:`borrowIn` ,`collateralSpent`, `repayAmount`, `collateralReturn`(Collateral return after repayment), `addCollateral`, `removeCollateral`, `collateralReturnAfterLiquidation` - **startTime** (int) - Optional - - **endTime** (int) - Optional - - **limit** (int) - Optional - Default: 10; max: 100 - **recvWindow** (int) - Optional - ### Request Example ```php getCryptoLoansIncomeHistory($asset, $type, $startTime, $endTime, $limit, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling StableRateApi->getCryptoLoansIncomeHistory: ', $e->getMessage(), PHP_EOL; } ``` ### Response #### Success Response (200) - **total** (int) - - **rows** (array) - #### Response Example ```json { "total": 100, "rows": [ { "asset": "USDT", "type": "borrowIn", "time": 1678886400000, "amount": "100.00000000", "loanAmount": "100.00000000", "interest": "0.00000000" } ] } ``` ``` -------------------------------- ### Initialize SimpleEarnRestApi with Configuration Source: https://github.com/binance/binance-connector-php/blob/master/src/simple-earn/README.md Initialize the SimpleEarnRestApi client using a configuration builder. This example demonstrates setting API keys and private key paths for authentication. The private key can be provided directly or via a file path. ```php use Binance\Client\Spot\Api\SimpleEarnRestApi; use Binance\Client\Spot\SimpleEarnRestApiUtil; $configurationBuilder = SimpleEarnRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey') ->privateKey('file:///path/to/private.key') // Provide the private key directly as a string or specify the path to a private key file (e.g., '/path/to/private_key.pem') ->privateKeyPass('myPrivateKeyPass'); // Optional: Required if the private key is encrypted $api = new SimpleEarnRestApi($configurationBuilder->build()); ``` -------------------------------- ### Get SOL Staking History Source: https://github.com/binance/binance-connector-php/blob/master/src/staking/docs/Api/SolStakingApi.md Retrieves the historical data for SOL staking. This method allows filtering by start and end times, and pagination. ```APIDOC ## GET /api/v1/staking/sol/history ### Description Retrieves the historical data for SOL staking. This method allows filtering by start and end times, and pagination. ### Method GET ### Endpoint /api/v1/staking/sol/history ### Parameters #### Query Parameters - **startTime** (int) - Optional - The start time for the query. - **endTime** (int) - Optional - The end time for the query. - **current** (int) - Optional - Currently querying page. Start from 1. Default:1 - **size** (int) - Optional - Default:10, Max:100 - **recvWindow** (int) - Optional - The window in milliseconds that the request must be completed in. ### Response #### Success Response (200) - **data** (object) - The response data containing staking history. ### Response Example ```json { "data": { "total": 100, "list": [ { "time": 1678886400000, "amount": "10.50000000", "type": "STAKE", "txId": "0xabc123" } ] } } ``` ``` -------------------------------- ### New Client Initialization Source: https://github.com/binance/binance-connector-php/blob/master/src/staking/docs/rest-api/migration-guide.md Example of initializing the modularized Staking Connector client. ```php $configurationBuilder = StakingRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new StakingRestApi($configurationBuilder->build()); ``` -------------------------------- ### Get Loan Repayment History Source: https://github.com/binance/binance-connector-php/blob/master/src/crypto-loan/docs/Api/StableRateApi.md Retrieves the repayment history for crypto loans. This method supports filtering by order ID, loan coin, collateral coin, start time, and end time. If start and end times are omitted, the system defaults to returning the last 90 days of data. The maximum time interval between start and end times is 180 days. ```php getLoanRepaymentHistory($orderId, $loanCoin, $collateralCoin, $startTime, $endTime, $current, $limit, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling StableRateApi->getLoanRepaymentHistory: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Update Client Initialization (Old Example) Source: https://github.com/binance/binance-connector-php/blob/master/src/derivatives-trading-options/docs/rest-api/migration-guide.md An example of the old client initialization for the Binance Spot API. ```php $client = new Binance\/Spot([ 'key' => $key, 'privateKey' => $privateKey, # pass the key file directly 'baseURL' => 'https://testnet.binance.vision' ]); ``` -------------------------------- ### Get Spot Rebate History Records Source: https://github.com/binance/binance-connector-php/blob/master/src/rebate/docs/Api/RebateApi.md Retrieves historical records for spot rebates. Supports filtering by start and end times, with a default of the last 7 days. The maximum interval between start and end times is 30 days. Supports up to 200 records per request. ```APIDOC ## GET /sapi/v1/rebate/taxQuery ### Description Get Spot Rebate History Records (USER_DATA) ### Method GET ### Endpoint /sapi/v1/rebate/taxQuery ### Parameters #### Query Parameters - **startTime** (int) - Optional - The start timestamp for the query. - **endTime** (int) - Optional - The end timestamp for the query. - **page** (int) - Optional - The page number for pagination. Defaults to 1. - **recvWindow** (int) - Optional - The time in milliseconds the server waits for the request to be processed. ### Request Example ```php getSpotRebateHistoryRecords($startTime, $endTime, $page, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling RebateApi->getSpotRebateHistoryRecords: ', $e->getMessage(), PHP_EOL; } ``` ### Response #### Success Response (200) - **response** (object) - Contains the rebate history records. #### Response Example ```json { "code": 200, "msg": "success", "list": [ { "tranId": "1234567890", "amount": "10.50000000", "createTime": 1678886400000, "type": "SPOT_REBATE" } ], "total": 100 } ``` ``` -------------------------------- ### Old Client Initialization Source: https://github.com/binance/binance-connector-php/blob/master/src/convert/docs/rest-api/migration-guide.md Example of initializing the client using the old structure. ```php $key = ''; # api key is also required $privateKey = 'file:///path/to/rsa/private/key.pem'; $client = new Binance\Spot([ 'key' => $key, 'privateKey' => $privateKey, # pass the key file directly 'baseURL' => 'https://testnet.binance.vision' ]); ``` -------------------------------- ### Get NFT Deposit History - PHP Source: https://github.com/binance/binance-connector-php/blob/master/src/nft/docs/Api/NFTApi.md Fetches the deposit history for NFTs. You can filter by start and end times, limit, page, and recvWindow. If start and end times are omitted, recent 7 days' data is returned. The maximum interval between startTime and endTime is 90 days. ```php getNFTDepositHistory($startTime, $endTime, $limit, $page, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling NFTApi->getNFTDepositHistory: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get UM Income History Source: https://github.com/binance/binance-connector-php/blob/master/src/derivatives-trading-portfolio-margin/docs/Api/AccountApi.md Retrieves the income history for a specified symbol and income type. Supports filtering by start and end times, pagination, and limit. ```APIDOC ## GET /api/v3/income (not provided in source, inferred from method name) ### Description Retrieves the income history for a specified symbol and income type. Supports filtering by start and end times, pagination, and limit. ### Method GET ### Endpoint /api/v3/income ### Parameters #### Query Parameters - **symbol** (string) - Optional - The trading symbol. - **incomeType** (string) - Optional - The type of income. Possible values: TRANSFER, WELCOME_BONUS, REALIZED_PNL, FUNDING_FEE, COMMISSION, INSURANCE_CLEAR, REFERRAL_KICKBACK, COMMISSION_REBATE, API_REBATE, CONTEST_REWARD, CROSS_COLLATERAL_TRANSFER, OPTIONS_PREMIUM_FEE, OPTIONS_SETTLE_PROFIT, INTERNAL_TRANSFER, AUTO_EXCHANGE, DELIVERED_SETTELMENT, COIN_SWAP_DEPOSIT, COIN_SWAP_WITHDRAW, POSITION_LIMIT_INCREASE_FEE. - **startTime** (int) - Optional - Timestamp in ms to get funding from INCLUSIVE. - **endTime** (int) - Optional - Timestamp in ms to get funding until INCLUSIVE. - **page** (int) - Optional - The page number for pagination. - **limit** (int) - Optional - Default 100; max 1000. The number of results per page. - **recvWindow** (int) - Optional - The window in milliseconds that the request must be completed in. ### Response #### Success Response (200) - **income** (array) - Description of income entries. ### Response Example ```json { "income": [ { "incomeType": "REALIZED_PNL", "incomeAmount": "10.5", "asset": "USDT", "time": 1678886400000, "symbol": "BTCUSDT", "tranId": "123456789" } ] } ``` ``` -------------------------------- ### Initialize Derivatives Trading Options Client (Old) Source: https://github.com/binance/binance-connector-php/blob/master/src/derivatives-trading-options/docs/rest-api/migration-guide.md This shows the old method of initializing the Binance Spot client. ```php $key = ''; # api key is also required $privateKey = 'file:///path/to/rsa/private/key.pem'; $client = new Binance\/Spot([ 'key' => $key, 'privateKey' => $privateKey, # pass the key file directly 'baseURL' => 'https://testnet.binance.vision' ]); ``` -------------------------------- ### Get Klines Source: https://github.com/binance/binance-connector-php/blob/master/src/alpha/docs/Api/MarketDataApi.md Retrieves historical kline (candlestick) data for a specified symbol and interval. Supports filtering by start and end times, and limiting the number of results. ```APIDOC ## GET /api/v1/klines ### Description Retrieves historical kline (candlestick) data for a specified symbol and interval. Supports filtering by start and end times, and limiting the number of results. ### Method GET ### Endpoint /api/v1/klines ### Parameters #### Query Parameters - **symbol** (string) - Required - e.g., "ALPHA_175USDT" – use token ID from Token List - **interval** (string) - Required - e.g., "1h" – supported intervals: 1s, 15s, 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M - **limit** (int) - Optional - number of results to return (default 500, max 1000) - **startTime** (int) - Optional - start timestamp (milliseconds) - **endTime** (int) - Optional - end timestamp (milliseconds) ### Response #### Success Response (200) - **data** (array) - Array of kline data ### Response Example ```json { "data": [ [ 1499040000000, // Open time "0.01634790", // Open "0.80000000", // High "0.01575800", // Low "0.01577100", // Close "12345.6789", // Volume 1499644799999, // Close time "2312.3456", // Quote asset volume 13, // Number of trades "1234.5678", // Taker buy base asset volume "1234.5678", // Taker buy quote asset volume "17928899.62483729" // Ignore. ] ] } ``` ``` -------------------------------- ### Get VIP Loan Interest Rate History - PHP Source: https://github.com/binance/binance-connector-php/blob/master/src/vip-loan/docs/Api/MarketDataApi.md Fetches the VIP Loan interest rate history for a specific coin. You can filter by start and end times, and control pagination with current page and limit parameters. The maximum interval between start and end times is 180 days. ```php getVIPLoanInterestRateHistory($coin, $recvWindow, $startTime, $endTime, $current, $limit); print_r($result); } catch (Exception $e) { echo 'Exception when calling MarketDataApi->getVIPLoanInterestRateHistory: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### New Client Initialization Source: https://github.com/binance/binance-connector-php/blob/master/src/fiat/docs/rest-api/migration-guide.md Example of initializing the FiatRestApi client with the new modular structure. ```php $configurationBuilder = FiatRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new FiatRestApi($configurationBuilder->build()); ``` -------------------------------- ### New Client Initialization Source: https://github.com/binance/binance-connector-php/blob/master/src/rebate/docs/rest-api/migration-guide.md Initialize the new RebateRestApi client using the ConfigurationBuilder. ```php $configurationBuilder = RebateRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new RebateRestApi($configurationBuilder->build()); ``` -------------------------------- ### Get Flexible Loan Borrow History Source: https://github.com/binance/binance-connector-php/blob/master/src/crypto-loan/docs/Api/FlexibleRateApi.md Fetches the borrowing history for flexible loans. If start and end times are not provided, it returns the most recent 90 days of data. The maximum time interval between start and end times is 180 days. Use this to review past borrowing activities. ```php getFlexibleLoanBorrowHistory($loanCoin, $collateralCoin, $startTime, $endTime, $current, $limit, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling FlexibleRateApi->getFlexibleLoanBorrowHistory: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### New Client Initialization Source: https://github.com/binance/binance-connector-php/blob/master/src/simple-earn/docs/rest-api/migration-guide.md Initialize the new SimpleEarnRestApi client using the ConfigurationBuilder. ```php $configurationBuilder = SimpleEarnRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new SimpleEarnRestApi($configurationBuilder->build()); ``` -------------------------------- ### Get Asset Dividend Record Source: https://github.com/binance/binance-connector-php/blob/master/src/wallet/docs/Api/AssetApi.md Retrieves a record of asset dividends. Requires asset, start time, and end time. Optional parameters include limit and recvWindow. ```php assetDividendRecord($asset, $startTime, $endTime, $limit, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling AssetApi->assetDividendRecord: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Order Status - PHP Source: https://github.com/binance/binance-connector-php/blob/master/src/derivatives-trading-usds-futures/docs/Api/ConvertApi.md Retrieves the status of a conversion order using either the order ID or quote ID. Ensure you have the necessary client and dependencies installed. ```php orderStatus($orderId, $quoteId); print_r($result); } catch (Exception $e) { echo 'Exception when calling ConvertApi->orderStatus: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Initialize SpotRestApi with Configuration Source: https://github.com/binance/binance-connector-php/blob/master/src/spot/README.md Instantiate the SpotRestApi client for interacting with the Binance SPOT API. Configure API keys, private keys, and optional passphrases for authentication. The private key can be provided directly or as a file path. ```php use Binance\Client\Spot\Api\SpotRestApi; use Binance\Client\Spot\SpotRestApiUtil; $configurationBuilder = SpotRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey') ->privateKey('file:///path/to/private.key') // Provide the private key directly as a string or specify the path to a private key file (e.g., '/path/to/private_key.pem') ->privateKeyPass('myPrivateKeyPass'); // Optional: Required if the private key is encrypted $api = new SpotRestApi($configurationBuilder->build()); ``` -------------------------------- ### Initialize NFT Client (Old vs. New) Source: https://github.com/binance/binance-connector-php/blob/master/src/nft/docs/rest-api/migration-guide.md Illustrates the difference in client initialization between the old monolithic structure and the new modularized NFT API, which uses a configuration builder. ```php $key = ''; # api key is also required $privateKey = 'file:///path/to/rsa/private/key.pem'; $client = new \Binance\Spot([ 'key' => $key, 'privateKey' => $privateKey, # pass the key file directly 'baseURL' => 'https://testnet.binance.vision' ]); ``` ```php $configurationBuilder = NftRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new NftRestApi($configurationBuilder->build()); ``` -------------------------------- ### Get Flexible Loan Interest Rate History Source: https://github.com/binance/binance-connector-php/blob/master/src/crypto-loan/docs/Api/FlexibleRateApi.md Retrieves the interest rate history for flexible loans. Supports filtering by coin, time range, and pagination. If start and end times are not provided, the last 90 days of data are returned. The maximum interval between start and end times is 90 days. ```php getFlexibleLoanInterestRateHistory($coin, $recvWindow, $startTime, $endTime, $current, $limit); print_r($result); } catch (Exception $e) { echo 'Exception when calling FlexibleRateApi->getFlexibleLoanInterestRateHistory: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get UM Account Trade List Source: https://github.com/binance/binance-connector-php/blob/master/src/derivatives-trading-portfolio-margin/docs/Api/TradeApi.md Retrieve a list of trades for a specific account and UM symbol. If start and end times are omitted, the last 7 days of data are returned. The time difference between start and end times cannot exceed 7 days. The `fromId` parameter cannot be used with `startTime` or `endTime`. Weight: 5. ```php umAccountTradeList($symbol, $startTime, $endTime, $fromId, $limit, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling TradeApi->umAccountTradeList: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Initialize Client (New) Source: https://github.com/binance/binance-connector-php/blob/master/src/alpha/docs/rest-api/migration-guide.md Initialize the modularized AlphaRestApi client using AlphaRestApiUtil for configuration. ```php $configurationBuilder = AlphaRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new AlphaRestApi($configurationBuilder->build()); ``` -------------------------------- ### Get Loan LTV Adjustment History Source: https://github.com/binance/binance-connector-php/blob/master/src/crypto-loan/docs/Api/StableRateApi.md Retrieves the history of LTV adjustments for a specific loan order. Parameters like order ID, loan coin, collateral coin, start and end times, current page, limit, and receive window can be specified. If start and end times are not provided, recent data is returned. ```php getLoanLtvAdjustmentHistory($orderId, $loanCoin, $collateralCoin, $startTime, $endTime, $current, $limit, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling StableRateApi->getLoanLtvAdjustmentHistory: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Initialize New Client Source: https://github.com/binance/binance-connector-php/blob/master/src/derivatives-trading-usds-futures/docs/rest-api/migration-guide.md Initialize the new modularized USDS Futures client using the configuration builder. ```php $configurationBuilder = DerivativesTradingUsdsFuturesRestApiUtil::getConfigurationBuilder(); $configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key'); $api = new DerivativesTradingUsdsFuturesRestApi($configurationBuilder->build()); ``` -------------------------------- ### Get Historical Trades - PHP Source: https://github.com/binance/binance-connector-php/blob/master/src/spot/docs/Api/MarketApi.md Retrieves historical trades for a symbol, starting from a specified trade ID. This endpoint has a request weight of 25. The limit parameter is optional and defaults to 500. ```php historicalTrades($symbol, $limit, $fromId); print_r($result); } catch (Exception $e) { echo 'Exception when calling MarketApi->historicalTrades: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Boost Rewards History (PHP) Source: https://github.com/binance/binance-connector-php/blob/master/src/staking/docs/Api/SolStakingApi.md Retrieves the history of boost rewards. Specify the type, start and end times, and pagination parameters. The time between `startTime` and `endTime` cannot be longer than 3 months. ```php getBoostRewardsHistory($type, $startTime, $endTime, $current, $size, $recvWindow); print_r($result); } catch (Exception $e) { echo 'Exception when calling SolStakingApi->getBoostRewardsHistory: ', $e->getMessage(), PHP_EOL; } ?> ```