Search code examples
githubgithub-api

Read-only property for GitHub repos via the API


I'm working on a GitHub app using their API, and trying to figure out if a repo I'm querying is in read-only mode (eg. this one is: https://github.com/carhartl/jquery-cookie).

I've searched through their docs, and the response, but can't seem to determine if a repo is in read-only mode.

Anyone have any experience with this, or else know of something I can use in the response body to determine/infer that a repo is in read-only mode?


Solution

  • For archived repos (read-only), the original changelog (a year ago, Nov. 2017) did not mention of any associated API.

    It only mention about a search feature.

    https://github.com/search?utf8=%E2%9C%93&q=archived%3Atrue+GNOME&type=

    That would match repositories that are archived and contain the word "GNOME."

    So maybe you could try a search for that repo, with the archived:true qualifier.
    If the search returns your repo, it is archived.


    A simpler approach, when querying a GitHub repository

    GET /repos/:owner/:repo
    

    The answer will include an "archived" field

    "archived": false,
    # or
    "archived": true,