Search code examples
github-api

How to tell if a repo is active or disabled using the GitHub API v3?


I'm using /user/repos?type=member&per_page=100&access_token=MYTOKEN and that returns all of the repos that I'm a member of.

However, some of the repos are disabled when I go to github.com/owner_name/repo/branches, it says that the repo is disabled.

But the API response gives no indication of this. Is there any way to tell?


Solution

  • I asked Github support and got the following response:

    The API matches the behavior of github.com with regard to disabled repositories. When you sign in and visit https://github.com, you'll see a list of repositories that you have access to under "Your repositories" (on the right-hand side). You should see repo_owner/DISABLED-REPO in that list. If you click on that repository in the list, you should be taken to the page for that repository, but also get a message that the repository has been disabled.

    The API provides the same information. If you fetch the list of repositories, the API tells you that you have access to that repository. However, to determine that it has been disabled, you'll need to fetch the repository itself -- there is no special "disabled" attribute when you fetch a list of repositories, which you are doing.

    So, try making this request:

    https://api.github.com/repos/repo_owner/DISABLED-REPO?access_token=MYTOKEN
    

    You should see a 403 Forbidden status with a helpful message in the body.

    Also, I'll pass your question/suggestion to the team to consider including a "disabled" attribute when fetching a list of repositories. However, I can't make any promises about if/when that might happen.