Public/Get-PSPublicAPIRandomEntry.ps1
<#
.SYNOPSIS Get a random public API entry .DESCRIPTION Gets a random API entry public API service or a random API entry matching a specific criteria .PARAMETER Title Specifies a substring from the public API title. No wildcards supported. .PARAMETER Description Specifies a substring from the public API description. No wildcards supported. .PARAMETER Authentication Specifies type of authentication supported by the API. This can be either null or a specific value supported by API like oauth. .PARAMETER HttpsOnly A switch parameter that specifies if only https supported APIs should be returned .PARAMETER Cors Specifies the CORS support within the public API. Valid values are yes, no, and unknown. .PARAMETER Category Specifies the category of the public API. .EXAMPLE Get-PSPublicAPIEntry -Verbose This command returns all the entries from the public API service .EXAMPLE Get-PSPublicAPIEntry -Title at -Verbose This command returns all the entries from the public API service where the title contains a substring at. #> function Get-PSPublicAPIRandomEntry { [CmdletBinding()] param ( [Parameter()] [String] $Title, [Parameter()] [String] $Description, [Parameter()] [String] $Authentication, [Parameter()] [Switch] $HttpsOnly, [Parameter()] [ValidateSet('yes', 'no', 'unknown')] [String] $Cors, [Parameter()] [String] $Category ) $uri = "${baseUri}random" $queryParameters = @{ } if ($Title) { $queryParameters.Add('title', $Title) } if ($Description) { $queryParameters.Add('description', $Description) } if ($Authentication) { $queryParameters.Add('auth', $Authentication) } if ($HttpsOnly) { $queryParameters.Add('https', $true) } if ($Cors) { $queryParameters.Add('cors', $Cors) } if ($Category) { $queryParameters.Add('category', $Category) } $queryUri = New-HttpQueryString -Uri $uri -QueryParameter $queryParameters $entries = (Invoke-RestMethod -Method Get -UseBasicParsing -Uri $queryUri).Entries return $entries } |