I want to get a list of my private repositories from GitHub. In the GitHub REST API documentation it states that the visibility
as private
can be supplied as parameter. But I don't know how to do it.
I am able to get a list of my public repositories using the following command in command line
curl -u "username:password" -X GET https://mygithuburl.com/users/username/repos
How to supply the visibility
parameter to private
to get a list of only the private repos?
You can supply the parameters as regular query string arguments:
Many API methods take optional parameters. For
GET
requests, any parameters not specified as a segment in the path can be passed as an HTTP query string parameter:curl -i "https://api.github.com/repos/vmg/redcarpet/issues?state=closed"
In this example, the 'vmg' and 'redcarpet' values are provided for the
:owner
and:repo
parameters in the path while:state
is passed in the query string.
In your case:
curl \
-u "username:password" \
-X GET \
https://mygithuburl.com/user/repos?visibility=private