Created
December 1, 2022 16:30
-
-
Save fabricesemti80/0b7394b79082eb03b922f33cc73f627c to your computer and use it in GitHub Desktop.
task-solution-for-interview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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