0

I only need the "stepSize" part in the "symbol" and "filterType": "LOT_SIZE" part via the API I use. Since it is a very complicated api, how should it be "foreach" and beyond?

api sample;

"timezone": "UTC",
"serverTime": 1602329180305,
"rateLimits": [
{
    "rateLimitType": "REQUEST_WEIGHT",
    "interval": "MINUTE",
    "intervalNum": 1,
    "limit": 1200
},
{
    "rateLimitType": "ORDERS",
    "interval": "SECOND",
    "intervalNum": 10,
    "limit": 100
},
{
    "rateLimitType": "ORDERS",
    "interval": "DAY",
    "intervalNum": 1,
    "limit": 200000
}
],
"exchangeFilters": [],
"symbols": [
{
    "symbol": "ETHBTC",
    "status": "TRADING",
    "baseAsset": "ETH",
    "baseAssetPrecision": 8,
    "quoteAsset": "BTC",
    "quotePrecision": 8,
    "quoteAssetPrecision": 8,
    "baseCommissionPrecision": 8,
    "quoteCommissionPrecision": 8,
    "orderTypes": [ "LIMIT", "LIMIT_MAKER", "MARKET", "STOP_LOSS_LIMIT", "TAKE_PROFIT_LIMIT" ],
    "icebergAllowed": true,
    "ocoAllowed": true,
    "quoteOrderQtyMarketAllowed": true,
    "isSpotTradingAllowed": true,
    "isMarginTradingAllowed": true,
    "filters": [
        {
            "filterType": "PRICE_FILTER",
            "minPrice": "0.00000100",
            "maxPrice": "100000.00000000",
            "tickSize": "0.00000100"
        },
        {
            "filterType": "PERCENT_PRICE",
            "multiplierUp": "5",
            "multiplierDown": "0.2",
            "avgPriceMins": 5
        },
        {
            "filterType": "LOT_SIZE",
            "minQty": "0.00100000",
            "maxQty": "100000.00000000",
            "stepSize": "0.00100000"
        },
        {
            "filterType": "MIN_NOTIONAL",
            "minNotional": "0.00010000",
            "applyToMarket": true,
            "avgPriceMins": 5
        },
        {
            "filterType": "ICEBERG_PARTS",
            "limit": 10
        },
        {
            "filterType": "MARKET_LOT_SIZE",
            "minQty": "0.00000000",
            "maxQty": "7479.60184990",
            "stepSize": "0.00000000"
        },
        {
            "filterType": "MAX_NUM_ORDERS",
            "maxNumOrders": 200
        },
        {
            "filterType": "MAX_NUM_ALGO_ORDERS",
            "maxNumAlgoOrders": 5
        }
    ],
    "permissions": [ "SPOT", "MARGIN" ]
},
...

but with the php code I am using, I cannot pull these two data. My goal is to just get "stepSize" data in SYMBOL and LOT_SIZE. Where could there be a mistake?

MY PHP Code;

<?php   

          $connect = mysqli_connect("localhost", "", "", "");

          $query = '';

          $table_data = '';

          $filename = "https://www.binance.com/api/v1/exchangeInfo";

          $data = file_get_contents($filename); //Read the JSON file in PHP

          $array = (json_decode($data, true)); //Convert JSON String into PHP Array

          foreach($array["symbols"]["symbol"]["filters"][3]["stepSize"] as $symbols)
          

          {

           $query .= "INSERT INTO lotsize (symbol, lotsize )  VALUES('".$symbols["symbol"]."', '".$symbols["stepSize"]."'); ";
           mysqli_multi_query($connect, $query))

          ?>

  • `$array['symbols']` is an array, you need to loop over it or index it. And the `symbol` element is not an array, so you can't use `["symbol"]["filters"]`. – Barmar Apr 15 '21 at 16:31
  • `foreach ($array['symbols'] as $symbol)` and then insert `$symbol['symbol']` and `$symbol['filters'][3]['stepSize']` – Barmar Apr 15 '21 at 16:32
  • Are you sure `stepSize` will always be in `filters[3]`? It would be better to loop over `$symbol['filters']` to find the one with `filterType == LOT_SIZE` – Barmar Apr 15 '21 at 16:34

0 Answers0