Question about using nuget API to query a package

sacheu 1 Reputation point Microsoft Employee
2020-12-19T23:07:23.193+00:00

I have a nuget package in

https://www.nuget.org/packages/Azure.Communication.Chat/1.0.0-beta.3

When I query it using the query REST API, like:

https://azuresearch-usnc.nuget.org/query?q=Azure.Communication.Chat&prerelease=true

I only get this:

{"@Георгий Георгиевский ":{"@vocab":"http://schema.nuget.org/schema#","@BASE ":"https://api.nuget.org/v3/registration5-semver1/"},"totalHits":0,"data":[]}

Can you please tell me why i don't see any result in the reponse?

Thank you.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,346 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Dylan Zhu-MSFT 6,406 Reputation points
    2020-12-21T06:43:38.237+00:00

    Hi sacheu,

    Please have a try this code to search your package:

            ILogger logger = NullLogger.Instance;  
            CancellationToken cancellationToken = CancellationToken.None;  
            SourceRepository repository = Repository.Factory.GetCoreV3("https://api.nuget.org/v3/index.json");  
            PackageSearchResource resource = await repository.GetResourceAsync<PackageSearchResource>();  
            SearchFilter searchFilter = new SearchFilter(includePrerelease: true);  
    
            IEnumerable<IPackageSearchMetadata> results = await resource.SearchAsync(  
                "Azure.Communication.Chat",  
                searchFilter,  
                skip: 0,  
                take: 10,  
                logger,  
                cancellationToken);  
    
            foreach (IPackageSearchMetadata result in results)  
            {  
                Console.WriteLine($"Found package {result.Identity.Id} {result.Identity.Version}");  
            }  
    

    Best Regards, Dylan

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our * *documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**

    0 comments No comments

  2. sacheu 1 Reputation point Microsoft Employee
    2020-12-21T16:45:40.813+00:00

    Thanks. But how can I achieve the same using REST API?


  3. sacheu 1 Reputation point Microsoft Employee
    2020-12-23T16:59:37.187+00:00

    I tried this url https://api.nuget.org/v3-flatcontainer/azure.communication.chat/index.json but it only gives me versions, not other information, like download statistics.