MyGet Public feed API

574 Views Asked by At

I am working on a Utility that verifies your project.json file in an ASP.NET application.

I want to verify that the packages referenced in project.json actually exist.

For this I require access to the MyGet public feed. Is there an API and where can I find the docs?

2

There are 2 best solutions below

0
On BEST ANSWER

I was able to figure out the API. MyGet uses an OData API which is publicly accessible.

Here is a good link on OData

An example of a sample query I constructed:

https://www.myget.org/F/aspnet/api/v2/Packages()?$format=json
2
On

A NuGet client can consume the MyGet package source in the same way it can consume the official NuGet package source.

I am not aware of any documentation for accessing a NuGet package source. However using the NuGet or MyGet package source is fairly straightforward if you use the .NET client library NuGet.Core, which is available as a NuGet package. The main thing that you need is the IPackageRepository interface which has various methods you can use to query the NuGet package source.

An example is shown below that connects to the official NuGet package source and checks if a package exists.

string url = "https://www.nuget.org/api/v2/";
IPackageRepository repo = PackageRepositoryFactory.Default.CreateRepository(url);
bool result = repo.Exists("NuGet.Core", new SemanticVersion("2.8.2"));