在哪里可以找到有关NuGet v3 API的文档? [英] Where can I find documentation for the NuGet v3 API?
问题描述
我有兴趣以非.NET语言围绕NuGet v3 API编写客户端库.我在哪里可以找到有关文件/资源的信息,例如向哪个URL发出请求,返回什么响应?
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?
我尝试过快速进行Google搜索,但唯一出现的是此,最近更新于3年前.规范存在吗?
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?
推荐答案
此处是正式的NuGet V3 API文档.该API由多种协议组成,包括:
Here is the official NuGet V3 API documentation. The API is composed of multiple protocols, including:
- 服务索引-客户端用于发现NuGet服务
- 搜索服务-由客户搜索NuGet软件包
- 注册-json-基于LD的结构,用于存储软件包的元数据.这包括程序包的内容,依赖项,描述等...
- "PackageBaseAddress" -存储,其中包含实际的软件包及其清单文件(
nuspec
).
- The Service Index - used by the client to discover the NuGet services
- The Search Service - used by clients to search for NuGet packages
- The Registration - A json-LD based structure that stores the packages' metadata. This includes packages' content, dependencies, descriptions, etc...
- The "PackageBaseAddress" - The store that contains the actual packages and their manifest files (the
nuspec
).
例如,假设您要下载软件包"Newtonsoft. 杰森":
For example, say you wanted to download the package "Newtonsoft. Json":
- 获取服务索引:`GET https://api.nuget.org/v3/index .json
响应包含PackageBaseAddress的地址(又名不正确,是平面容器,因为它是分层的而不是flat :)):
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"
},
- 使用@id提供的uri作为基本uri列出所需软件包的版本:
GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
,请注意,此uri可能会更改,并且不属于API - 使用相同的基本uri下载软件包:
GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/6.0.4/newtonsoft.json.6.0.4.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
您可能还希望查看 NuGet客户端一个>.客户端的源代码是 此处;您需要从 NuGet.CommandLine开始项目并沿着堆栈走下去.
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.
这篇关于在哪里可以找到有关NuGet v3 API的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!