GET API 请求 github 回购

GET API request to github repo

所以,我有一个获取请求:

https://api.github.com/users/exampleName/repos

这个 returns json 个对象的列表,这些对象是该用户拥有的所有 public 个存储库。

如果我想通过 full_name 之类的

获得他的特定回购协议之一怎么办
https://api.github.com/users/exampleName/repos/?full_name=exampleFull_name.

我试过了,但没用。

我不确定如何在 api 调用中从列表中检索特定的 Json 对象。

如有任何帮助,我们将不胜感激。

如果您已经知道 repo 名称,则请求的 URL 是:

https://api.github.com/repos/[user]/[repo]

其中 [user] 是仓库所有者的 GitHub 用户名,[repo] 是仓库名称。

GitHub Docs

示例:

https://api.github.com/repos/octocat/Hello-World

如果您直接知道用户名和存储库。您可以只生成 url:

https://api.github.com/repos/{username}/{reponame}

如果您不知道存储库名称,则必须执行多个 API 查询。

首先您需要获取 public 回购列表:

https://api.github.com/users/exampleName/repos

然后您需要遍历所有存储库并找到与您想要的名称相匹配的名称。例如,您想要名为 ExampleRepository 的存储库。一旦获得与您想要的相匹配的回购对象。您可以获得该存储库的 url

[
  {
    ...
    "name": "ExampleRepository",
    "url": "https://api.github.com/repos/ExampleName/ExampleRepository",
  },
  ...
]