Scripts/Get-CoinbaseTradingPairList.ps1


Function Get-CoinbaseTradingPairList {

    <#
 
    .SYNOPSIS
 
    Gets a list of available currency pairs for trading.
 
    .DESCRIPTION
 
    Gets a list of available currency pairs for trading.
 
    .PARAMETER
 
    .EXAMPLE
 
    Get-CoinbaseTradingPairList
 
    .NOTES
 
    .LINK
 
    #>


    [CmdletBinding ()]

    Param ()

    BEGIN {

        Function Show-Output ($Values) {

            [PSCustomObject]@{

                Name = $Values.Display_Name
                Id = $Values.Id
                BaseCurrency = $Values.Base_Currency
                QuoteCurrency = $Values.Quote_currency
                QuoteIncrement = $Values.Quote_Increment
                BaseIncrement = $Values.Base_Increment
                MinimumMarketFunds = $Values.Min_Market_Funds
                MarginEnabled = $Values.Margin_Enabled
                PostOnly = $Values.Post_Only
                LimitOnly = $Values.Limit_Only
                CancelOnly = $Values.Cancel_Only
                TradingDisabled = $Values.Trading_Disabled
                StableCoin = $Values.Fx_StableCoin
                MaximumSlippagePercentage = $Values.Max_Slippage_Percentage
                AuctionMode = $Values.Auction_Mode
                HighBidLimitPercentage = $Values.High_Bid_Limit_Percentage
                Status = $Status

            }

        }

    }

    PROCESS {

        Try {

            $Headers = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]'
            $Headers.Add('Content-Type', 'application/json')

            $Response = Invoke-RestMethod 'https://api.exchange.coinbase.com/products' -Method 'GET' -Headers $Headers

            ForEach ($Item In $Response) {

                $Status = 'Ok'

                Show-Output ($Item)

            }

        }

        Catch {

            $Status = $PSItem.Exception.Message

            Show-Output ('')

        }

    }

    END {}

}