What is the best way to parallel process Invoke-RestMethod
?
I'm trying to retrieve a list of coin prices, currently I'm using a foreach
loop to retrieve the price. Doing this with 30 odd coins takes a while:
$coins = @("XRP", "TRX", "VEN", "CND", "ICX", "XLM", "BNB")
$base = "ETH"
while ($true) {
foreach ($coin in $coins) {
$pair = $coin + $base
$uri = "https://api.binance.com/api/v3/ticker/price?symbol=$pair"
$price = Invoke-RestMethod -Method Get -URI $uri |
select Price -ExpandProperty Price
Write-Host $price
}
}