Skip to content

Instantly share code, notes, and snippets.

@fabricesemti80
Created December 1, 2022 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabricesemti80/0b7394b79082eb03b922f33cc73f627c to your computer and use it in GitHub Desktop.
Save fabricesemti80/0b7394b79082eb03b922f33cc73f627c to your computer and use it in GitHub Desktop.
task-solution-for-interview
<#
Using any scripting language make a request to this API endpoint https://api.publicapis.org/entries
Then filter down all the objects by category "Blockchain".
#>
# search category
$category = "Blockchain" #or: $category = "Animals"
# URL definition
$endpointUri = "https://api.publicapis.org/entries"
# all return data
$data = Invoke-RestMethod -Uri $endpointUri
# all entries from the return data
$entries = $data.entries
# filter the results matching the given category
$entries | Where-Object {$_.Category -match $category}
# or oneliner
(Invoke-RestMethod -Uri "https://api.publicapis.org/entries").entries | Where-Object {$_.Category -match "Blockchain"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment