Hi all,
Since I posted on my reverse engineering task on the v3 API, I thought: why not, for reference, add something on the v2 API as well?
Now, its a lie that this post originated from that thought, it actually originated from someone asking me what the v2 API looks like. But anyway, here goes :-)
The feed at https://www.nuget.org/api/v2/ exposes an OData (v3?) endpoint that provides a couple of things (see https://www.nuget.org/api/v2/$metadata if you prefer reading XML over text and for full details on parameter names and types):
* The Packages collection which can be queried using standard OData syntax. Note that the NuGet Gallery prevents doing some things to safeguard load on the database, but in general if your own v2 endpoint supports most common OData queries, the NuGet client will be fine. Because in fact, the NuGet client uses this Packages collection very little! Instead, it relies on the next three exposed operations on the OData endpoint.
* The Search operation, taking a searchTerm, targetFramework and the fact if you want to include prereleases or not. The searchTerm parameter can be plain text *or* a Lucene query, for example "id:NuGet.Core" will tell the Lucene index to search in the id field.
* The FindPackagesById operation, which returns all packages for a specific package ID.
* The GetUpdates operation, which returns all updated packages based on parameters passed in (there are quite a few if you check the metadata)
You'd think that is it? Well... No! The PowerShell CmdLets that are exposed in Visual Studio, use two additional endpoints. These are two JSON endpoints that are not part of the OData API:
* https://www.nuget.org/api/v2/package-ids?partialId=GoogleAnalytics – returning a JSON-serialized array of package id’s that match the partialId parameter (max. 30 entries)
* https://www.nuget.org/api/v2/package-versions/NuGet.Core – returning a JSON-serialized array of all versions of a specific package
Closing note: The NuGet v2.0 API and the v1.0 API are very, very similar. The main difference is the properties of packages being returned and the Screenshots collection being returned (see Orchard). If you want to support Orchard, it's worth looking into their OData endpoint. Other than that I don't think anyone else is still usign the v1 endpoint.
Best regards,
Maarten