In this article we show you how to display various crypto currency rates using powershell
Depending on when you read this and what the status of the crypto market is – you may be checking these frequently and are very nervous because of the latest crypto crash
Code
There are masses of api’s available at https://min-api.cryptocompare.com/documentation?api_key= , some of these need api keys, some are free with no api key. This is one of these
In this example we want the following cryptos
GetCryptoRate BTC “Bitcoin”
GetCryptoRate ETH “Ethereum”
GetCryptoRate ADA “Cardano”
GetCryptoRate DOGE “Dogecoin”
GetCryptoRate DOT “Polkadot”
GetCryptoRate SOL “Solana”
GetCryptoRate LTC “Litecoin”
And we want to convert these to GBP, USD and EUR
There are more cryptocurrencies available and many fiat currencies that are available, check the documentation at the api site
<# .SYNOPSIS Lists the latest crypto exchange rates .DESCRIPTION This script lists the latest crypto exchange rates. .EXAMPLE PS> ./get-crypto-rates #> function GetCryptoRate { param([string]$Symbol, [string]$Name) $Rates = (invoke-webRequest -uri "https://min-api.cryptocompare.com/data/price?fsym=$Symbol&tsyms=USD,EUR,GBP" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json new-object PSObject -property @{ 'Cryptocurrency' = "1 $Name ($Symbol) ="; 'USD' = "$($Rates.USD)"; 'EUR' = "$($Rates.EUR)"; 'GBP' = "$($Rates.GBP)" } } function GetCryptoRates { GetCryptoRate BTC "Bitcoin" GetCryptoRate ETH "Ethereum" GetCryptoRate ADA "Cardano" GetCryptoRate DOGE "Dogecoin" GetCryptoRate DOT "Polkadot" GetCryptoRate SOL "Solana" GetCryptoRate LTC "Litecoin" } try { "" "Latest Crypto Exchange Rates from cryptocompare" "=============================" GetCryptoRates | format-table -property @{e='Cryptocurrency';width=20},USD,EUR,GBP exit 0 } catch { "Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" exit 1 }
Output
This is what i saw at the time of running this
Latest Crypto Exchange Rates from cryptocompare ============================= Cryptocurrency USD EUR GBP -------------- --- --- --- 1 Bitcoin (BTC) = 37807.81 33928.02 28230.99 1 Ethereum (ETH) = 2536.99 2275.79 1892.6 1 Cardano (ADA) = 1.055 0.9464 0.7868 1 Dogecoin (DOGE) = 0.1417 0.1271 0.1058 1 Polkadot (DOT) = 18.38 16.48 13.72 1 Solana (SOL) = 92.41 83.02 69 1 Litecoin (LTC) = 109.7 98.4 81.95