Search code examples
pythongithubgithub-api

Retrieve list of all repositories from a github user (public and private ones)


Hello everyone I'm trying to create a very simple python script that creates a list of tuples, repository name and clone url for each repository (public and private ones) of a github user owns. I have read a lot of threads about it but none solved my issue. There is no problem in getting the public ones. I have create a personal access token with full repo scope but I manage to retrieve only the public ones again.

I have tried making requests like this:
https://api.github.com/users/my_username/repos?access_token=my_personal_access_token

I have also read about pygithub3 library but I would prefer not to use it.


Solution

  • You should use the /user/repos API.

    /users/<username>/repos will only return the public repositories for obvious reasons, and it is also documented (emphasis is mine):

    Lists public repositories for the specified user.

    GET /users/:username/repos