I'm interested in writing a client library for the NuGet v3 API in a non-.NET language.
What are the requests required to get a package, and what does the response looks like?
i.e.
GET {package-versions} GET {package-version}
Can you also link to the official documentation that covers this scenario?
Here is the official NuGet V3 API documentation. The API is composed of multiple protocols, including:
nuspec
).For example, say you wanted to download the package "Newtonsoft. Json":
Get the service index: GET https://api.nuget.org/v3/index.json
The response contains the address of the PackageBaseAddress (aka, incorrectly as the flat container, as it is hierarchical and not flat :) ):
{
"@id": "https://api.nuget.org/v3-flatcontainer/",
"@type": "PackageBaseAddress/3.0.0",
"comment": "Base URL of Azure storage where NuGet package registration info for DNX is stored, in the format https://api.nuget.org/v3-flatcontainer/{id-lower}/{version-lower}.{version-lower}.nupkg"
},
Use the uri provided by the @id as a base uri to list the versions of the desired package: GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
, note that this uri is subject to change and is not part of the API
Use the same base uri to download a package: GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/6.0.4/newtonsoft.json.6.0.4.nupkg
You may also want to look at the NuGet client. The client's source code is here; you'll want to start from the NuGet.CommandLine project and walk your way down the stack.