60262186
Lok Sze Decoration Engineering Limited
Flat C7, 5/F, Tung Lee Factory Building, 9 Lai Yip Street, Kwun Tong, Kowloon

  • 中文 (香港)
  • English
  • Ethereum: Finding data for Binance USDT-M trading commissions on my orders with Binance API

    Ethereum: Finding Data for Binance USDT-M Trading Commissions on Binance API

    As a Binance NPM user with NodeJS, you are probably familiar with the Binance API, which provides access to various trading data and market information. However, it can be difficult to know the commissions charged for your orders. In this article, we will learn how to retrieve commission data from the Binance API.

    Understanding Trading Commissions

    Trading commissions are fees charged by exchanges for buying or selling assets on their platforms. For Binance USDT-M (US Dollar Tether-Minted), the fee structure is as follows:

    • Long market orders: 0.1% of the trade value
    • Short market orders: 0.3% of the trade value

    Accessing trading commissions via Binance API

    Ethereum: Findinf data for Binance USDT-M trading commissions on my orders with Binance API

    To access trading commissions, you need to use the “GET /spot/tradingCommission” endpoint on the Binance API. This endpoint returns a list of available commission rates for different assets.

    Here is an example of how to make a GET request using the Binance API with NodeJS:

    const axios = require('axios');

    const apiKey = 'YOUR_API_KEY';

    const apiSecret = 'YOUR_API_SECRET';

    const endpoint =

    async function getTradingCommissions() {

    const response = wait axios.get(endpoint, {

    headers: {

    'X-MBX-APIKEY': apiKey,

    'X-MBX-SECRET-KEY': apiSecret

    }

    });

    const commissions = response.data;

    return commissions;

    }

    getTradingCommissions().then(commissions => {

    console.log(commissions);

    }).catch(error => {

    console.error(error);

    });

    Retrieving commission data for a specific asset

    To retrieve commission data for a specific asset (in this case, USDT-M), you need to modify the GET /spot/tradingCommissionendpoint to include the desired asset.

    For example, to get commissions for USDT-M:

    const endpoint = tradingCommission?symbol=USDT-M;

    Accessing commission data with Binance API V2

    As of January 2021, the Binance API has been updated to use a new version (v2). To access commission data using version 2, you need to replace GET /exchangeinfo/spot/tradingCommissionwithGET /trades.

    Here is an example of how to make a GET request using the Binance API v2:

    const api = require('axios');

    api.get('/trades?symbol=USDT-M')

    .then(data => {

    console.log(data);

    })

    .catch(error => {

    console.error(error);

    });

    Example Use Case

    Suppose you want to track the commission charged for a long market order on USDT-M. You can use the GET /spot/tradingCommissionendpoint to retrieve the commission data:

    const apiKey = 'YOUR_API_KEY';

    const apiSecret = 'YOUR_API_SECRET';

    async function getLongMarketOrderCommission() {

    const response = wait axios.get( tradingCommission?symbol=USDT-M`);

    return response.data;

    }

    getLongMarketOrderCommission().then(commissions => {

    console.log(commissions);

    }).catch(error => {

    console.error(error);

    });

    By following these steps, you should be able to access the commissions charged for your orders on the Binance API. Remember to replace "YOUR_API_KEY" and "YOUR_API_SECRET" with your actual Binance API credentials.

    Conclusion

    Finding trading commission data on the Binance API may seem daunting at first, but it’s actually quite simple once you understand how to use the appropriate endpoint and parameters. By following these examples, you should be able to track commission data for long market orders on USDT-M using both the old and new versions of the Binance API. Happy trading!