Tag Archives: binance

Sample Binance API queries

Getting All Isolated Margin Symbols in PHP:

$api_key = "*****";
$secret = "*****";

$opt = [
    "http" => [
        "method" => "GET",
        "header" => "User-Agent: Mozilla/4.0 (compatible; PHP Binance API)\r\nX-MBX-APIKEY: {$api_key}\r\n"
    ]
];
$context = stream_context_create($opt);
$params['timestamp'] = number_format(microtime(true)*1000,0,'.','');
$query = http_build_query($params, '', '&');
$signature = hash_hmac('sha256', $query, $secret);
$endpoint = "https://api.binance.com/sapi/v1/margin/isolated/allPairs?{$query}&signature={$signature}";

$res = file_get_contents($endpoint, false, $context);
echo $res;
(more…)