Where can I find documentation for the NuGet v3 API?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 09:11:25

问题


I'm interested in writing a client library around the NuGet v3 API in a non-.NET language. Where can I find documentation/resources on it that would tell me e.g. what URLs to make requests to and what responses it would return?

I tried doing a quick Google search, but the only thing that turns up is this, which was last updated 3 years ago. Does a spec exist?


回答1:


Here is the official NuGet V3 API documentation. The API is composed of multiple protocols, including:

  1. The Service Index - used by the client to discover the NuGet services
  2. The Search Service - used by clients to search for NuGet packages
  3. The Registration - A json-LD based structure that stores the packages' metadata. This includes packages' content, dependencies, descriptions, etc...
  4. The "PackageBaseAddress" - The store that contains the actual packages and their manifest files (the nuspec).

For example, say you wanted to download the package "Newtonsoft. Json":

  1. 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"
},
  1. 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
  2. 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.




回答2:


Recently official V3 documentation was published here



来源:https://stackoverflow.com/questions/34958908/where-can-i-find-documentation-for-the-nuget-v3-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!