Is it possible to search a package from all Artifact Feeds in Azure DevOps?

Viewed 233

I know it's possible to get all packages contained in a single Artifact Feed using the link below:

https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/Feeds/{feedId}/packages?api-version=6.0-preview.1

I noticed in Azure DevOps that the search bar has the ability to look into ALL feeds inside a project. Thus, my question is: Is it possible to achieve the same functionality through the API, and get all packages from all feeds instead of one.

1 Answers

Is it possible to achieve the same functionality through the API, and get all packages from all feeds instead of one.

As far as I know, this is achievable.

You could use the Rest API -Feed Management - Get Feeds to get All feeds in Project level.

Then you could use the Rest API to get the packages. You can execute these two apis simultaneously through powershell.

Here is the Powershell sample:

$token = "PAT"

$url="https://feeds.dev.azure.com/{Organization Name}/{Project Name}/_apis/packaging/feeds?api-version=6.0-preview.1"

$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))



$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json




ForEach( $feedid in $response.value.id ) 
{


    echo $feedid
  
    $url1="https://feeds.dev.azure.com/{Organization Name}/{Project Name}/_apis/packaging/Feeds/$($feedid)/packages?api-version=6.0-preview.1"
   


    $response1 = Invoke-RestMethod -Uri $url1 -Headers @{Authorization = "Basic $token"} -Method Get  -ContentType application/json

    Write-Host "Package = $($response1 | ConvertTo-Json -Depth 100)"
        
    
}

In this case, you can get alls feeds of project scope in a project, and then get all the packages in it.

By the way, if you want to get all organization scope feeds, you only need to delete the project parameter in the URL.

Related