praeclarum / FuGetGallery

An alternative web UI for browsing nuget packages
https://www.fuget.org
MIT License
683 stars 121 forks source link

Update to use NuGet.org's new search service #74

Closed loic-sharma closed 5 years ago

loic-sharma commented 5 years ago

See: https://devblogs.microsoft.com/nuget/new-and-improved-nuget-search/ For example: https://azuresearch-usnc.nuget.org/query?prerelease=true&semVerLevel=2.0.0&q=Microsoft.Extensions.Logging

We will be deleting the old search service soon and the URL will no longer exist.

loic-sharma commented 5 years ago

By the way @praeclarum, would you be interested in using a third-party SDK that handles the nitty gritties of the NuGet protocol (like finding the correct search URL)? The usage would be something like:

var client = new NuGetClient("https://api.nuget.org/v3/index.json");
var response = await client.SearchAsync("json");

Console.WriteLine($"Found {response.TotalHits} results");

var index = 1;
foreach (var searchResult in response.Data)
{
    Console.WriteLine($"Result #{index}");
    Console.WriteLine($"Package id: {searchResult.PackageId}");
    Console.WriteLine($"Package version: {searchResult.Version}");
    Console.WriteLine($"Package downloads: {searchResult.TotalDownloads}");
    Console.WriteLine($"Package versions: {searchResult.Versions.Count}");
    Console.WriteLine();

    index++;
}

This is a side project that I'm working on, so let me know if you're interested 😄

praeclarum commented 5 years ago

Thanks for the stop-gap measure! I do promise to implement service provider... some day.

I don't love using 3rd party libraries to hit web APIs. But I'll admit that nuget's API is weird and breaky enough that it might warrant it. But honestly, I don't see the point.. I would end up changing a lot of code for no user-facing benefits - and I hate those kinds of "refactoring for the sake of refactoring" changes..

loic-sharma commented 5 years ago

I don't love using 3rd party libraries to hit web APIs. But I'll admit that nuget's API is weird and breaky enough that it might warrant it. But honestly, I don't see the point.. I would end up changing a lot of code for no user-facing benefits - and I hate those kinds of "refactoring for the sake of refactoring" changes..

That's fair. Ideally, the library abstracts away all the NuGet protocol's complexities so that you can focus on FuGet's functionality. This may be useful if you ever decide to support other NuGet servers (like Sleet or MyGet, all of which have their own quirks). If you're interested, I could send a pull request with all the necessary changes.