NuGet API call to get the latest version number of a package

Viewed 356

I have a test harness, in which I would like to verify the version number of a nuget package automatically.

I have been searching for a good while trying to find a way to get the latest version number (not the latest package) for a given package. But no luck.

Is there a way to get the latest version number of a package via an API? (Needs to be automatable).

If it matters, I am using ProGet for my NuGet repository.

1 Answers

This url template will get you the package info (in XML) of the latest version. You will then have to parse out the LatestVersion or AbosluteLatestVersion:

$"https://{yourNuGetRepositoryBaseUrl}/nuget/{feedName}/Packages()?$filter=Id%20eq%20%27{packageId}%27%20and%20IsLatestVersion&$top=1"

Note that this works with ProGet (that has many different feeds). You could probably omit the FeedName part to use it with NuGet.org.

Related