Public/Get-GW2CommerceListings.ps1

<#
    .SYNOPSIS
        Retrieves current buy and sell listings from the trading post.
 
    .DESCRIPTION
        The Get-GW2CommerceListings cmdlet retrieves current buy and sell listings for items.
 
    .PARAMETER Ids
        The ID(s) of the items to retrieve listings for. Can be a single ID, an array of IDs, or "all".
 
    .PARAMETER Page
        The page number to retrieve.
 
    .PARAMETER PageSize
        The number of results per page.
 
    .EXAMPLE
        Get-GW2CommerceListings -Ids 19684
        Retrieves listings for item ID 19684.
 
    .EXAMPLE
        Get-GW2CommerceListings -Ids "all"
        Retrieves all listings (paginated).
 
    .NOTES
        API Endpoint: /v2/commerce/listings
    #>

function Get-GW2CommerceListings {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [string[]]$Ids
    )

    $Uri = "https://api.guildwars2.com/v2/commerce/listings"
    if ($Ids) {
        $Uri += "?ids=" + ($Ids -join ",")
    }
    try {
        Invoke-RestMethod -Uri $Uri -Method Get
    }
    catch {
        Write-Error "Failed to retrieve commerce listings: $_"
    }
}