如何使用github API从特定用户获取特定存储库?

时间:2019-01-25 23:43:59

标签: rest api curl github repository

我用

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

有效。现在,我想获取特定的存储库,只需一个通过存储库名称的存储库即可,例如:

https://api.github.com/users/ahfarmer/repos/calculator

它不起作用。如何使用github API获得这个唯一的回购协议?

1 个答案:

答案 0 :(得分:2)

pattern是:

GET /repos/:owner/:repo

因此,在这种情况下,端点将为https://api.github.com/repos/ahfarmer/calculator

结果:

$ curl -s https://api.github.com/repos/ahfarmer/calculator | head -n 10
{
  "id": 70841075,
  "node_id": "MDEwOlJlcG9zaXRvcnk3MDg0MTA3NQ==",
  "name": "calculator",
  "full_name": "ahfarmer/calculator",
  "private": false,
  "owner": {
    "login": "ahfarmer",
    "id": 597825,
    "node_id": "MDQ6VXNlcjU5NzgyNQ==",