是否有适当的 header 用于在 REST Api 中发送客户端库信息?

Is there an appropriate header for sending client library information in a REST Api?

我想在调用 RESTful API 时发送我的客户端库的标识符。我们有 Java、C#、Ruby、Python 和其他语言的客户端库。例如,我的 Java 客户端库可以发送:

User-Agent: java/1.10.2

我的应用程序使用 User-Agent header 还是自定义 header 更好? User-Agent header 似乎更多地用于浏览器,我还没有找到将 header 用于客户端库的 API。

编辑

  1. 我们的客户使用客户端库来使用我们的 API,它处理所有请求和响应逻辑。这只是调用 API.
  2. 的简单方法
  3. 这些信息将仅用于统计,并在出现错误时帮助我们确定客户使用的客户端库版本。

我认为 User-Agent 在这种情况下是合适的 header。

根据WikipediaUser-Agent是:

a user agent is software (a software agent) that is acting on behalf of a user... In many cases, a user agent acts as a client in a network protocol used in communications within a client–server distributed computing system. In particular, the Hypertext Transfer Protocol (HTTP) identifies the client software originating the request, using a user-agent header, even when the client is not operated by a user.

因此,要成为User-Agent,应该是:

  1. 一个软件
  2. 网络协议中的客户端
  3. 代表用户

根据相关描述,客户端库(软件)用于代表用户使用API() 并处理 ALL 请求和响应逻辑(网络协议中的客户端),这使得它完全符合上述定义。

此外,客户端库信息的使用通常是普通浏览器的 User-Agent 的用途。