### Install and Use Coin-M Futures Connector Source: https://github.com/binance/binance-connector-js/blob/master/clients/derivatives-trading-coin-futures/README.md Install the library using npm and import the client. This example demonstrates how to initialize the client with API credentials and make a request to the exchange information endpoint. ```typescript import { DerivativesTradingCoinFutures } from '@binance/derivatives-trading-coin-futures'; const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', }; const client = new DerivativesTradingCoinFutures({ configurationRestAPI }); client.restAPI .exchangeInformation() .then((res) => res.data()) .then((data) => console.log(data)) .catch((err) => console.error(err)); ``` -------------------------------- ### Install and Use Derivatives Trading Portfolio Margin Pro Library Source: https://github.com/binance/binance-connector-js/blob/master/clients/derivatives-trading-portfolio-margin-pro/README.md Install the library using npm. Ensure your environment has Node.js version 22.12.0 or later. This example shows how to initialize the client and fetch account information. ```bash nvm install 22.12.0 nvm use 22.12.0 npm install @binance/derivatives-trading-portfolio-margin-pro ``` ```typescript import { DerivativesTradingPortfolioMarginPro } from '@binance/derivatives-trading-portfolio-margin-pro'; const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', }; const client = new DerivativesTradingPortfolioMarginPro({ configurationRestAPI }); client.restAPI .getPortfolioMarginProAccountInfo() .then((res) => res.data()) .then((data) => console.log(data)) .catch((err) => console.error(err)); ``` -------------------------------- ### Install New Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/convert/docs/migration_guide_convert_connector.md Install the new Convert-specific package, @binance/convert, to your project. ```bash npm install @binance/convert ``` -------------------------------- ### Install Binance Spot Connector Source: https://github.com/binance/binance-connector-js/blob/master/README.md Install the Binance Spot Trading connector package using npm. ```bash npm install @binance/spot ``` -------------------------------- ### Install @binance/common Package Source: https://github.com/binance/binance-connector-js/blob/master/common/README.md Install the package using npm to include it in your project. ```bash npm install @binance/common ``` -------------------------------- ### Install W3W Prediction Library Source: https://github.com/binance/binance-connector-js/blob/master/clients/w3w-prediction/README.md Install the Binance W3W Prediction library using npm. ```bash npm install @binance/w3w-prediction ``` -------------------------------- ### Install Node.js and Wallet Library Source: https://github.com/binance/binance-connector-js/blob/master/clients/wallet/README.md Ensure Node.js version 22.12.0 or later is installed. Then, install the library using npm. ```bash nvm install 22.12.0 nvm use 22.12.0 npm install @binance/wallet ``` -------------------------------- ### Install New Package (Step 2) Source: https://github.com/binance/binance-connector-js/blob/master/clients/copy-trading/docs/migration_guide_copy_trading_connector.md Install the new Copy Trading-specific package to replace the old one. ```bash npm install @binance/copy-trading ``` -------------------------------- ### Install Derivatives Trading Options Library Source: https://github.com/binance/binance-connector-js/blob/master/clients/derivatives-trading-options/README.md Install the Binance JavaScript Derivatives Trading Options library using npm. ```bash npm install @binance/derivatives-trading-options ``` -------------------------------- ### Install and Run Tests Source: https://github.com/binance/binance-connector-js/blob/master/clients/algo/README.md Installs project dependencies and runs the test suite for the Binance Connector JS. ```bash npm install npm run test ``` -------------------------------- ### Install New Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/copy-trading/docs/migration_guide_copy_trading_connector.md Uninstall the old package and install the new modularized Copy Trading package. ```bash npm uninstall @binance/connector npm install @binance/copy-trading ``` -------------------------------- ### Install New Wallet Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/wallet/docs/migration_guide_wallet_connector.md Command to install the new modularized Wallet Connector package. ```bash npm install @binance/wallet ``` -------------------------------- ### Install New Binance Simple Earn Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/simple-earn/docs/migration_guide_simple_earn_connector.md Command to install the new modularized '@binance/simple-earn' package. ```bash npm install @binance/simple-earn ``` -------------------------------- ### Install New Binance Dual Investment Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/dual-investment/docs/migration_guide_dual_investment_connector.md Command to install the new, modularized Dual Investment package. ```bash npm install @binance/dual-investment ``` -------------------------------- ### Install New NFT Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/nft/docs/migration_guide_nft_connector.md Install the new NFT-specific package, @binance/nft, to your project. ```bash npm install @binance/nft ``` -------------------------------- ### Install New Crypto Loan Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/crypto-loan/docs/migration_guide_crypto_loan_connector.md Command to install the new, modularized Crypto Loan-specific package. ```bash npm install @binance/crypto-loan ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/binance/binance-connector-js/blob/master/clients/margin-trading/README.md Install the necessary project dependencies before running tests or building the project. ```bash npm install ``` -------------------------------- ### Install New Binance Gift Card Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/gift-card/docs/migration_guide_gift_card_connector.md Install the dedicated @binance/giftcard package for Gift Card functionalities. ```bash npm install @binance/giftcard ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/binance/binance-connector-js/blob/master/clients/w3w-prediction/README.md Installs project dependencies and executes the test suite. Ensure all tests pass before contributing. ```bash npm install npm run test ``` -------------------------------- ### Install New Binance Pay Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/pay/docs/migration_guide_pay_connector.md Install the new, modularized '@binance/pay' package to integrate Binance Pay functionalities. ```bash npm install @binance/pay ``` -------------------------------- ### Install and Uninstall Packages Source: https://github.com/binance/binance-connector-js/blob/master/clients/vip-loan/docs/migration_guide_vip_loan_connector.md Use npm to uninstall the old package and install the new modularized VIP Loan package. ```bash npm uninstall @binance/connector npm install @binance/vip-loan ``` -------------------------------- ### Install New Convert Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/convert/docs/migration_guide_convert_connector.md Uninstall the old package and install the new @binance/convert package using npm. ```bash npm uninstall @binance/connector npm install @binance/convert ``` -------------------------------- ### Install Node.js and Library Source: https://github.com/binance/binance-connector-js/blob/master/clients/vip-loan/README.md Ensure your environment is running Node.js version 22.12.0 or later. Install the library using npm. ```bash nvm install 22.12.0 nvm use 22.12.0 npm install @binance/vip-loan ``` -------------------------------- ### Install Node.js and Library Source: https://github.com/binance/binance-connector-js/blob/master/clients/simple-earn/README.md Ensure your environment is running Node.js version 22.12.0 or later. Install the library using npm. ```bash nvm install 22.12.0 nvm use 22.12.0 npm install @binance/simple-earn ``` -------------------------------- ### Install Node.js and Library Source: https://github.com/binance/binance-connector-js/blob/master/clients/nft/README.md Ensure your environment is running Node.js version 22.12.0 or later. Install the library using npm. ```bash nvm install 22.12.0 nvm use 22.12.0 npm install @binance/nft ``` -------------------------------- ### Simple Earn Flexible Product List Example Source: https://github.com/binance/binance-connector-js/blob/master/clients/simple-earn/docs/rest-api/key-pair-authentication.md This example demonstrates how to initialize the Simple Earn client with key pair credentials and retrieve a list of flexible products. ```APIDOC ## Get Simple Earn Flexible Product List ### Description Retrieves a list of all available simple earn flexible products. ### Method GET ### Endpoint /api/v3/simple-earn/flexible/product/list ### Parameters #### Query Parameters None ### Request Example ```javascript client.restAPI.getSimpleEarnFlexibleProductList() ``` ### Response #### Success Response (200) - **data** (object) - Contains the list of flexible products. #### Response Example ```json { "data": [ { "productId": "1", "asset": "USDT", "avgApy": "5.00%", "்த்த": "5.50%" } ] } ``` ``` -------------------------------- ### SubAccountRestAPI Example Source: https://github.com/binance/binance-connector-js/blob/master/clients/sub-account/README.md Example demonstrating how to use the SubAccountRestAPI to get a summary of sub-accounts' margin accounts. This requires API key and secret for authentication. ```APIDOC ## getSummaryOfSubAccountsMarginAccount ### Description Retrieves a summary of sub-accounts' margin account information. ### Method GET ### Endpoint /sapi/v1/sub-account/margin/accountSummary ### Parameters #### Query Parameters - **subAccountName** (string) - Optional - The name of the sub-account. ### Request Example ```typescript import { SubAccount, SubAccountRestAPI } from '@binance/sub-account'; const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', }; const client = new SubAccount({ configurationRestAPI }); client.restAPI .getSummaryOfSubAccountsMarginAccount() .then((res) => res.data()) .then((data: SubAccountRestAPI.GetSummaryOfSubAccountsMarginAccountResponse) => console.log(data) ) .catch((err) => console.error(err)); ``` ### Response #### Success Response (200) - **subAccountList** (array) - List of sub-account margin account details. - **email** (string) - The email of the sub-account. - **marginAssetList** (array) - List of margin assets for the sub-account. - **asset** (string) - The asset name. - **availableBalance** (string) - The available balance for the asset. - **borrowedBalance** (string) - The borrowed balance for the asset. - **totalAsset** (string) - The total asset amount. #### Response Example ```json { "subAccountList": [ { "email": "sub1@example.com", "marginAssetList": [ { "asset": "USDT", "availableBalance": "100.00000000", "borrowedBalance": "0.00000000", "totalAsset": "100.00000000" } ] } ] } ``` ``` -------------------------------- ### Get Collateral Asset Data Source: https://github.com/binance/binance-connector-js/blob/master/clients/vip-loan/docs/rest-api/key-pair-authentication.md Example of making a call to retrieve collateral asset data using the authenticated VIPLoan client. ```APIDOC ## Get Collateral Asset Data ### Description Retrieves collateral asset data using the authenticated VIPLoan client. ### Method ```typescript client.restAPI.getCollateralAssetData() ``` ### Endpoint N/A (This is a client method call) ### Parameters None ### Request Example ```typescript client.restAPI .getCollateralAssetData() .then((res) => res.data()) .then((data: VIPLoanRestAPI.GetCollateralAssetDataResponse) => console.log(data)) .catch((err) => console.error(err)); ``` ### Response #### Success Response (200) - **data** (VIPLoanRestAPI.GetCollateralAssetDataResponse) - The collateral asset data. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Initialize Spot Client with Key Pair Authentication Source: https://github.com/binance/binance-connector-js/blob/master/clients/spot/docs/rest-api/key-pair-authentication.md Demonstrates how to initialize the Spot client using API key, private key, and an optional passphrase for encrypted private keys. ```APIDOC ## Initialize Spot Client with Key Pair Authentication ### Description This code snippet shows how to configure and instantiate the `Spot` client using key pair authentication. It includes placeholders for your API key, private key content or file path, and an optional passphrase if your private key is encrypted. ### Usage ```typescript import fs from 'fs'; import { Spot, SpotRestAPI } from '@binance/spot'; const apiKey = 'your-api-key'; const privateKey = 'your-private-key-content-or-file-path'; // Provide the private key directly as a string or specify the path to a private key file (e.g., '/path/to/private_key.pem') const privateKeyPassphrase = 'your-passphrase'; // Optional: Required if the private key is encrypted const configurationRestAPI = { apiKey, privateKey, privateKeyPassphrase, }; const client = new Spot({ configurationRestAPI }); // Example usage: Fetch account information client.restAPI .getAccount() .then((res) => res.data()) .then((data: SpotRestAPI.GetAccountResponse) => console.log(data)) .catch((err) => console.error(err)); ``` ### Parameters - `apiKey` (string): Your Binance API key. - `privateKey` (string): Your Binance private key content or the path to the private key file. - `privateKeyPassphrase` (string, optional): The passphrase for your private key if it is encrypted. Omit if not encrypted. ``` -------------------------------- ### Get Pay Trade History Source: https://github.com/binance/binance-connector-js/blob/master/clients/pay/README.md This example demonstrates how to fetch the pay trade history using the Binance Pay REST API client. It requires API key and secret for authentication. ```APIDOC ## GET /sapi/v1/pay/query/trade/history ### Description Retrieves the transaction history for Binance Pay. ### Method GET ### Endpoint /sapi/v1/pay/query/trade/history ### Parameters #### Query Parameters - **startTime** (integer) - Optional - The start time to query for trades. - **endTime** (integer) - Optional - The end time to query for trades. - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of results per page. ### Request Example ```javascript import { Pay, PayRestAPI } from '@binance/pay'; const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', }; const client = new Pay({ configurationRestAPI }); client.restAPI .getPayTradeHistory({ startTime: 1678886400000, endTime: 1678972800000, limit: 10 }) .then((res) => res.data()) .then((data: PayRestAPI.GetPayTradeHistoryResponse) => console.log(data)) .catch((err) => console.error(err)); ``` ### Response #### Success Response (200) - **code** (string) - Response code. - **message** (string) - Response message. - **data** (object) - Response data containing trade history. - **total** (integer) - Total number of trades. - **list** (array) - List of trade objects. - **orderId** (string) - Unique order ID. - **transactionType** (string) - Type of transaction. - **amount** (string) - Transaction amount. - **currency** (string) - Transaction currency. - **status** (string) - Transaction status. - **createTimestamp** (integer) - Timestamp of creation. - **updateTimestamp** (integer) - Timestamp of last update. #### Response Example ```json { "code": "000000", "message": "Success", "data": { "total": 1, "list": [ { "orderId": "1234567890", "transactionType": "PAY_TO_USER", "amount": "10.00", "currency": "USDT", "status": "SUCCESS", "createTimestamp": 1678886400000, "updateTimestamp": 1678886460000 } ] } } ``` ``` -------------------------------- ### Initialize Spot Client with Configuration Source: https://github.com/binance/binance-connector-js/blob/master/clients/spot/docs/migration_guide_spot_connector.md Initialize the Spot client using the new modularized structure, passing configuration options. ```typescript import { Spot, SpotRestAPI } from '@binance/spot'; const configurationRestAPI = { apiKey: 'your-key', apiSecret: 'your-secret', }; const client = new Spot({ configurationRestAPI }); client.restAPI.exchangeInfo().then(console.log); ``` -------------------------------- ### Get Fiat Deposit/Withdraw History Source: https://github.com/binance/binance-connector-js/blob/master/clients/fiat/README.md This example demonstrates how to retrieve the Fiat Deposit/Withdraw history using the REST API client. It requires API key and secret for authentication and allows filtering by transaction type. ```APIDOC ## GET /sapi/v1/fiat/deposit_withdraw_history ### Description Retrieves the Fiat Deposit/Withdraw history. ### Method GET ### Endpoint /sapi/v1/fiat/deposit_withdraw_history ### Parameters #### Query Parameters - **transactionType** (string) - Required - Type of transaction: "0" for deposit, "1" for withdraw. ### Request Example ```typescript import { Fiat, FiatRestAPI } from '@binance/fiat'; const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', }; const client = new Fiat({ configurationRestAPI }); client.restAPI .getFiatDepositWithdrawHistory({ transactionType: '0' }) .then((res) => res.data()) .then((data: FiatRestAPI.GetFiatDepositWithdrawHistoryResponse) => console.log(data)) .catch((err) => console.error(err)); ``` ### Response #### Success Response (200) - **data** (FiatRestAPI.GetFiatDepositWithdrawHistoryResponse) - The response data containing the transaction history. ``` -------------------------------- ### Disable Keep-Alive in Fiat REST API Client Source: https://github.com/binance/binance-connector-js/blob/master/clients/fiat/docs/rest-api/keepAlive.md Set `keepAlive` to `false` in the `configurationRestAPI` object to disable persistent connections. This example demonstrates disabling Keep-Alive and making a request to get fiat deposit/withdraw history. ```typescript import { Fiat, FiatRestAPI } from '@binance/fiat'; const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', keepAlive: false, // Default is true }; const client = new Fiat({ configurationRestAPI }); client.restAPI .getFiatDepositWithdrawHistory({ transactionType: '0' }) .then((res) => res.data()) .then((data: FiatRestAPI.GetFiatDepositWithdrawHistoryResponse) => console.log(data)) .catch((err) => console.error(err)); ``` -------------------------------- ### Disable Keep-Alive for VIP Loan REST API Client Source: https://github.com/binance/binance-connector-js/blob/master/clients/vip-loan/docs/rest-api/keepAlive.md Instantiate the VIP Loan client with `keepAlive` set to `false` to disable persistent connections. This example demonstrates disabling keep-alive and making a request to get collateral asset data. ```typescript import { VIPLoan, VIPLoanRestAPI } from '@binance/vip-loan'; const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', keepAlive: false, // Default is true }; const client = new VIPLoan({ configurationRestAPI }); client.restAPI .getCollateralAssetData() .then((res) => res.data()) .then((data: VIPLoanRestAPI.GetCollateralAssetDataResponse) => console.log(data)) .catch((err) => console.error(err)); ``` -------------------------------- ### Configure HTTPS Agent for Coin Futures Client Source: https://github.com/binance/binance-connector-js/blob/master/clients/derivatives-trading-coin-futures/docs/rest-api/httpsAgent.md Set up a custom HTTPS agent with `rejectUnauthorized` set to true and use it to configure the Coin Futures client. This ensures secure communication by validating SSL certificates. The example then makes a call to `exchangeInformation` to verify the client setup. ```typescript import https from 'https'; import { DerivativesTradingCoinFutures } from '@binance/derivatives-trading-coin-futures'; const httpsAgent = new https.Agent({ rejectUnauthorized: true, }); const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', httpsAgent, }; const client = new DerivativesTradingCoinFutures({ configurationRestAPI }); client.restAPI .exchangeInformation() .then((res) => res.data()) .then((data) => console.log(data)) .catch((err) => console.error(err)); ``` -------------------------------- ### Old Spot Client Initialization Source: https://github.com/binance/binance-connector-js/blob/master/clients/spot/docs/migration_guide_spot_connector.md Example of how the Spot client was initialized in the previous monolithic package. ```typescript const client = new Spot({ apiKey: 'your-key', apiSecret: 'your-secret' }); client.exchangeInformation().then(console.log); ``` -------------------------------- ### Initialize Rebate Client with Key Pair Authentication Source: https://github.com/binance/binance-connector-js/blob/master/clients/rebate/docs/rest-api/key-pair-authentication.md Demonstrates how to initialize the Rebate client using API key and private key for authentication. It shows how to provide the private key directly or via a file path, and how to include a passphrase for encrypted keys. ```APIDOC ## Initialize Rebate Client with Key Pair Authentication ### Description This snippet shows how to configure and instantiate the Rebate client using API key and private key credentials. It covers scenarios where the private key is provided as a string or from a file, and how to handle an optional passphrase for encrypted private keys. ### Method Instantiate the `Rebate` class with `configurationRestAPI` object. ### Parameters - `apiKey` (string) - Your Binance API key. - `privateKey` (string) - Your Binance private key content or the path to the private key file. - `privateKeyPassphrase` (string, optional) - The passphrase for your encrypted private key. Required if the private key is encrypted. ### Request Example ```typescript import fs from 'fs'; import { Rebate, RebateRestAPI } from '@binance/rebate'; const apiKey = 'your-api-key'; const privateKey = 'your-private-key-content-or-file-path'; // Or '/path/to/private_key.pem' const privateKeyPassphrase = 'your-passphrase'; // Optional const configurationRestAPI = { apiKey, privateKey, privateKeyPassphrase, }; const client = new Rebate({ configurationRestAPI }); ``` ### Usage Example ```typescript client.restAPI .getSpotRebateHistoryRecords() .then((res) => res.data()) .then((data: RebateRestAPI.GetSpotRebateHistoryRecordsResponse) => console.log(data)) .catch((err) => console.error(err)); ``` ``` -------------------------------- ### Initialize Wallet Client with Key Pair Source: https://github.com/binance/binance-connector-js/blob/master/clients/wallet/docs/rest-api/key-pair-authentication.md Demonstrates how to import necessary modules, configure API credentials (API key, private key, and passphrase), and initialize the Wallet client for REST API interactions. ```APIDOC ## Initialize Wallet Client with Key Pair ### Description This example shows how to set up the Binance Wallet client using API key and private key for authentication. It covers importing modules, defining credentials, and initializing the client. ### Language ```typescript import fs from 'fs'; import { Wallet, WalletRestAPI } from '@binance/wallet'; const apiKey = 'your-api-key'; const privateKey = 'your-private-key-content-or-file-path'; // Provide the private key directly as a string or specify the path to a private key file (e.g., '/path/to/private_key.pem') const privateKeyPassphrase = 'your-passphrase'; // Optional: Required if the private key is encrypted const configurationRestAPI = { apiKey, privateKey, privateKeyPassphrase, }; const client = new Wallet({ configurationRestAPI }); client.restAPI .accountInfo() .then((res) => res.data()) .then((data: WalletRestAPI.AccountInfoResponse) => console.log(data)) .catch((err) => console.error(err)); ``` ### Usage 1. Replace `'your-api-key'`, `'your-private-key-content-or-file-path'`, and `'your-passphrase'` with your actual credentials. 2. If your private key is encrypted, ensure `privateKeyPassphrase` is provided. 3. Execute the script to authenticate and fetch account information. ``` -------------------------------- ### Update Client Initialization Example Source: https://github.com/binance/binance-connector-js/blob/master/clients/fiat/docs/migration_guide_fiat_connector.md Demonstrates the old way of initializing a client versus the new modularized approach for the Fiat connector. ```typescript const client = new Fiat({ apiKey: 'your-key', apiSecret: 'your-secret' }); ``` ```typescript import { Fiat, FiatRestAPI } from '@binance/spot'; const configurationRestAPI = { apiKey: 'your-key', apiSecret: 'your-secret', }; const client = new Fiat({ configurationRestAPI }); ``` -------------------------------- ### Update Client Initialization Example Source: https://github.com/binance/binance-connector-js/blob/master/clients/dual-investment/docs/migration_guide_dual_investment_connector.md Demonstrates the updated way to initialize the client for the modular Dual Investment connector. ```typescript const client = new Spot({ apiKey: 'your-key', apiSecret: 'your-secret' }); ``` ```typescript import { DualInvestment, DualInvestmentRestAPI } from '@binance/dual-investment'; const configurationRestAPI = { apiKey: 'your-key', apiSecret: 'your-secret', }; const client = new DualInvestment({ configurationRestAPI }); ``` -------------------------------- ### Install New Mining Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/mining/docs/migration_guide_mining_connector.md Command to install the new modularized Mining-specific package. ```bash npm install @binance/mining ``` -------------------------------- ### Install Binance Types Package Source: https://github.com/binance/binance-connector-js/blob/master/types/README.md Install the @binance/types package using npm to include it in your project. ```bash npm install @binance/types ``` -------------------------------- ### Initialize VIPLoan Client with Key Pair Source: https://github.com/binance/binance-connector-js/blob/master/clients/vip-loan/docs/rest-api/key-pair-authentication.md This snippet shows how to import the necessary classes, configure the API key, private key, and passphrase, and then initialize the VIPLoan client for REST API interactions. ```APIDOC ## Initialize VIPLoan Client with Key Pair ### Description Demonstrates how to set up the VIPLoan client using API key and private key for authentication. ### Method ```typescript new VIPLoan({ configurationRestAPI }) ``` ### Parameters #### Configuration Object - **apiKey** (string) - Required - Your API key. - **privateKey** (string) - Required - Your private key content or path to the private key file. - **privateKeyPassphrase** (string) - Optional - The passphrase for your private key if it's encrypted. ### Request Example ```typescript import fs from 'fs'; import { VIPLoan, VIPLoanRestAPI } from '@binance/vip-loan'; const apiKey = 'your-api-key'; const privateKey = 'your-private-key-content-or-file-path'; // Provide the private key directly as a string or specify the path to a private key file (e.g., '/path/to/private_key.pem') const privateKeyPassphrase = 'your-passphrase'; // Optional: Required if the private key is encrypted const configurationRestAPI = { apiKey, privateKey, privateKeyPassphrase, }; const client = new VIPLoan({ configurationRestAPI }); ``` ``` -------------------------------- ### Install New Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/algo/docs/migration_guide_algo_connector.md Command to add the new modular @binance/algo package to your project. ```bash npm install @binance/algo ``` -------------------------------- ### Update Client Initialization for Spot Source: https://github.com/binance/binance-connector-js/blob/master/clients/spot/docs/migration_guide_spot_connector.md Demonstrates the updated method for initializing the Spot client with configuration in the modularized package. ```typescript import { Spot, SpotRestAPI } from '@binance/spot'; const configurationRestAPI = { apiKey: 'your-key', apiSecret: 'your-secret', }; const client = new Spot({ configurationRestAPI }); ``` -------------------------------- ### Install New Fiat Package Command Source: https://github.com/binance/binance-connector-js/blob/master/clients/fiat/docs/migration_guide_fiat_connector.md Install the new Fiat-specific package using npm. ```bash npm install @binance/fiat ``` -------------------------------- ### REST API Example Source: https://github.com/binance/binance-connector-js/blob/master/clients/derivatives-trading-options/README.md This example demonstrates how to initialize the client and make a call to the option account information endpoint using the REST API. ```APIDOC ## REST API Example ### Description This example demonstrates how to initialize the client and make a call to the option account information endpoint using the REST API. ### Method ```typescript client.restAPI.optionAccountInformation() ``` ### Parameters This method does not take any parameters. ### Request Example ```typescript import { DerivativesTradingOptions } from '@binance/derivatives-trading-options'; const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', }; const client = new DerivativesTradingOptions({ configurationRestAPI }); client.restAPI .optionAccountInformation() .then((res) => res.data()) .then((data) => console.log(data)) .catch((err) => console.error(err)); ``` ### Response #### Success Response (200) - **data** (object) - The account information. #### Response Example ```json { "data": { "uid": "123456789", "email": "test@example.com", "ipRestrict": false, "tradeAndLeveragePositionLimit": "5", "creationTime": "1678886400000", "feeTier": "0", "canTrade": true, "canWithdraw": true, "enableFutures": true, "enableIsolatedMargin": true, "enableOption": true } } ``` ``` -------------------------------- ### Install New Modular Binance Connectors Source: https://github.com/binance/binance-connector-js/blob/master/MIGRATION.md Install the specific modular connector package required for your use case, such as Spot or COIN-M Futures. ```bash npm install @binance/spot ``` ```bash npm install @binance/derivatives-trading-coin-futures ``` -------------------------------- ### Initialize Spot Client with Key Pair Authentication Source: https://github.com/binance/binance-connector-js/blob/master/clients/spot/docs/rest-api/key-pair-authentication.md Configure the Spot client with your API key, private key (as a string or file path), and an optional passphrase for encrypted private keys. This setup is required for making authenticated requests. ```typescript import fs from 'fs'; import { Spot, SpotRestAPI } from '@binance/spot'; const apiKey = 'your-api-key'; const privateKey = 'your-private-key-content-or-file-path'; // Provide the private key directly as a string or specify the path to a private key file (e.g., '/path/to/private_key.pem') const privateKeyPassphrase = 'your-passphrase'; // Optional: Required if the private key is encrypted const configurationRestAPI = { apiKey, privateKey, privateKeyPassphrase, }; const client = new Spot({ configurationRestAPI }); client.restAPI .getAccount() .then((res) => res.data()) .then((data: SpotRestAPI.GetAccountResponse) => console.log(data)) .catch((err) => console.error(err)); ``` -------------------------------- ### Install New Binance C2C Package Source: https://github.com/binance/binance-connector-js/blob/master/clients/c2c/docs/migration_guide_c2c_connector.md Install the new modularized '@binance/c2c' package for C2C functionalities. ```bash npm install @binance/c2c ``` -------------------------------- ### Initialize Pay Client with Key Pair Authentication Source: https://github.com/binance/binance-connector-js/blob/master/clients/pay/docs/rest-api/key-pair-authentication.md Demonstrates how to initialize the Pay client using API key and private key for authentication. This includes options for providing the private key directly or via a file path, and handling private key passphrases for encrypted keys. ```APIDOC ## Initialize Pay Client with Key Pair Authentication ### Description This code snippet shows how to configure and initialize the `Pay` client using key pair authentication. It covers setting up the API key, private key (either as a string or a file path), and an optional passphrase for encrypted private keys. ### Usage 1. **Import necessary modules**: `fs` for file system operations and `Pay`, `PayRestAPI` from `@binance/pay`. 2. **Define credentials**: Set your `apiKey`, `privateKey`, and `privateKeyPassphrase` (if applicable). 3. **Configure `configurationRestAPI`**: Create an object with your authentication credentials. 4. **Instantiate the client**: Create a new `Pay` client instance with the configuration. 5. **Make an API call**: Example using `client.restAPI.getPayTradeHistory()`. ### Code Example ```typescript import fs from 'fs'; import { Pay, PayRestAPI } from '@binance/pay'; const apiKey = 'your-api-key'; const privateKey = 'your-private-key-content-or-file-path'; // Provide the private key directly as a string or specify the path to a private key file (e.g., '/path/to/private_key.pem') const privateKeyPassphrase = 'your-passphrase'; // Optional: Required if the private key is encrypted const configurationRestAPI = { apiKey, privateKey, privateKeyPassphrase, }; const client = new Pay({ configurationRestAPI }); client.restAPI .getPayTradeHistory() .then((res) => res.data()) .then((data: PayRestAPI.GetPayTradeHistoryResponse) => console.log(data)) .catch((err) => console.error(err)); ``` ### Parameters - **apiKey** (string): Your Binance API key. - **privateKey** (string): Your private key content or the path to the private key file. - **privateKeyPassphrase** (string, optional): The passphrase for your private key if it is encrypted. This is required only if the private key is encrypted. ``` -------------------------------- ### Keep-Alive Configuration Example Source: https://github.com/binance/binance-connector-js/blob/master/clients/pay/docs/rest-api/keepAlive.md This example demonstrates how to initialize the Pay client with keep-alive disabled and then make a request. ```APIDOC ## Keep-Alive Configuration This section shows how to configure the `keepAlive` option when initializing the Binance Pay client. ### Configuration The `keepAlive` option in the `configurationRestAPI` object controls whether to use persistent connections. The default value is `true`. ```typescript const configurationRestAPI = { apiKey: 'your-api-key', apiSecret: 'your-api-secret', keepAlive: false, // Default is true }; const client = new Pay({ configurationRestAPI }); // Example usage after configuration: client.restAPI .getPayTradeHistory() .then((res) => res.data()) .then((data: PayRestAPI.GetPayTradeHistoryResponse) => console.log(data)) .catch((err) => console.error(err)); ``` ### Purpose Setting `keepAlive` to `false` will disable persistent connections, meaning a new connection will be established for each request. This can be useful in specific scenarios but may lead to increased latency compared to using persistent connections. ```