-1

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 Answers2

1

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
0

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"));
Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • Unfortunately the NuGet library you pointed me to won't help. The tool I'm developing is supposed to be cross-platform, so I can't develop it in C#. NuGet is no good because the packages I am interested in are hosted on MyGet. I just need help finding the API docs for MyGet. – Sourabh Shirhatti Jun 27 '14 at 16:47
  • You should add your cross platform requirements to your question. However C# is cross platform. You can use NuGet on Mac, Linux and Windows. If you need to use it on mobile platforms you may need to create the http requests yourself. There are no API docs for NuGet or MyGet as far as I am aware. Did you try looking on the MyGet website? MyGet exposes the same the same API as NuGet. The NuGet API uses OData and so does the MyGet API. – Matt Ward Jun 27 '14 at 22:30