如何使用curl获取私有存储库?

时间:2019-01-25 14:03:45

标签: api curl github get

我想从GitHub获取我的私有存储库的列表。在GitHub REST API文档中,其声明为the visibility as private can be supplied as parameter。但是我不知道该怎么做。

我可以在命令行中使用以下命令来获取我的公共存储库列表

iconClicked(menuIcon: HTMLElement) {
    menuIcon.classList.add('flip');

    setTimeout(()=> {
        menuIcon.classList.remove('flip');
    }, 2000)
}

如何向curl -u "username:password" -X GET https://mygithuburl.com/users/username/repos 提供visibility参数以获取仅私有存储库的列表?

1 个答案:

答案 0 :(得分:1)

您可以supply the parameters as regular query string arguments

  

许多API方法采用可选参数。对于GET请求,任何未在路径中指定为段的参数都可以作为HTTP查询字符串参数传递:

curl -i "https://api.github.com/repos/vmg/redcarpet/issues?state=closed"
     

在此示例中,在查询字符串中传递:owner时,为路径中的:repo:state参数提供了'vmg'和'redcarpet'值。

在您的情况下:

curl \
    -u "username:password" \
    -X GET \
    https://mygithuburl.com/user/repos?visibility=private