In this article, I will explain how to use the API and get the information and rules for each pair available on Binance with PowerShell.
Before executing orders, we need to know the rules on a pair that we want to interact with. In order to gather information for a symbol, we request the endpoint /api/v3/exchangeInfo. The main utility is to obtain an exhaustive list of available pairs, obtain their status, what filters are used and what type of order is available.
As explained in my first post blog on this topic, all functions are written in PowerShell, my native language as I come from IT.
Function Get-ExchangeInfo
function Get-ExchangeInfo{ <# .SYNOPSIS Get current exchange trading rules and symbol information .EXAMPLE Get-ExchangeInfo .EXAMPLE Get-ExchangeInfo | ?{$_.symbol -eq "BTCUSDT"} | select -ExpandProperty quoteAssetPrecision .EXAMPLE Get-ExchangeInfo | ?{$_.symbol -like "*USDT*"} | sort symbol | Out-GridView .EXAMPLE (Get-ExchangeInfo | ?{$_.symbol -eq "BTCUSDT"}).filters | fl #> [cmdletbinding()] param( ) BEGIN{ $URL = "https://api.binance.com/api/v3/exchangeInfo" $ArraySymobols = @() } PROCESS{ $ExchangeInfo = curl $URL -Method get $ExchangeInfo = $ExchangeInfo.Content | ConvertFrom-Json $ExchangeSymbols = $ExchangeInfo.symbols # for unknown reason, the $web object is case sensitive foreach($Symbol in $ExchangeSymbols){ $ObjSymbols = [PSCustomObject]@{ symbol = $Symbol.symbol filters = $Symbol.filters quoteAsset = $Symbol.quoteAsset status = $Symbol.status orderTypes = $Symbol.orderTypes } $ArraySymobols += $ObjSymbols } } END{ return $ArraySymobols } }
About this function
- EndPoint /api/v3/exchangeInfo
An endpoint is simply an end of a communication channel. This one is part of the “General endpoints” and in comparison with the “Account endpoints”, it doesn’t require any authentication. - Curl is an alias of Invoke-WebRequest
This is the command used to request an API. The $Ticker variable is an HtmlWebResponsObject which contains a property Content, and this content is in JSON format. This is why | ConvertFrom-Json is used. - $ObjSymbols = [PSCustomObject]@{}
We create a PSCustomObject with a selected of properties. Add the property you want in the result returned in $ArraySymobols.
Examples


In the next post, we will see how to use the API with PowerShell to see how to authenticate ourselves on Binance and get ready to make our first transaction.
This might be simplified. Just use Select-Object
Invoke-WebRequest “https://api.binance.com/api/v3/exchangeInfo” -Method get |
ForEach-Object Content |
ConvertFrom-Json |
Foreach-Object symbols |
Select-Object symbol, filters, quoteAsset, status, orderTypes
Hi Pepa,
thanks for sharing!
this is true that I always have the same approach. I usually don’t try the one-liner and I like to create my own object to be more flexible.