我在哪里可以找到NuGet v3 API的文档?

Jam*_* Ko 13 .net c# nuget nuget-package nuget-server

我有兴趣用非.NET语言编写围绕NuGet v3 API的客户端库.我在哪里可以找到关于它的文档/资源,告诉我例如哪些URL提出请求以及它将返回什么响应?

我尝试过快速谷歌搜索,但唯一出现的是这个,这是3年前的最后一次更新.是否存在规范?

Yis*_*zer 19

是官方的NuGet V3 API文档.API由多种协议组成,包括:

  1. 服务指数 -由客户端用来发现的NuGet服务
  2. 搜索服务 -客户端用于搜索的NuGet包
  3. 登记 -基于JSON-LD结构,用于存储程序包的元数据.这包括包的内容,依赖关系,描述等......
  4. "PackageBaseAddress" -包含实际包及其清单文件(商店nuspec).

例如,假设您要下载"Newtonsoft.Json"软件包:

  1. 获取服务索引:`GET https://api.nuget.org/v3/index.json

响应包含PackageBaseAddress的地址(也就是说,错误地作为平面容器,因为它是分层的而不是平坦的:)):

{
  "@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"
},
Run Code Online (Sandbox Code Playgroud)
  1. 使用@id提供的uri作为基础uri列出所需包的版本:GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json请注意,此uri可能会更改,不属于API的一部分
  2. 使用相同的基本uri下载包: GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/6.0.4/newtonsoft.json.6.0.4.nupkg

您可能还想查看NuGet客户端.客户端的源代码在 这里 ; 你想要从NuGet.CommandLine项目开始,然后沿着堆栈走下去.