GitHub API/ Getting parent repos of a forked repo when listing all repos of a given user

Hi,

When listing all user’s repos using the following end point, the result is an array of summarized repositories (i.e it has fewer fields than the result for calling Get  for a single repository)

GET /users/:username/repos

In particualr, it does not include the _Parent _and Source subdocuments that are provided for forked repositories.

As far as I understand, the only way to get to the source of a user’s forked repository would be to then call Get for every forked repository on the list (resulting a pretty big overhead). Am I missing anything?

If not, would this be the place to ask to extend the summaried strcutre to include that information? :slight_smile:

thanks

These kinds of problems are why we are moving away from REST and toward GraphQL as our primary API. We have to constantly guess at what additional information people might want when they request certain information and strike a balance between convenience and performance. With GraphQL, you can simply state what information you want. For example, this is a quick stab at the kind of query you’re asking for:

query {
  user(login: "lee-dohm") {
    repositories(first: 100, isFork: true, privacy: PUBLIC) {
      nodes {
        nameWithOwner
        parent {
          nameWithOwner
        }
      }
    }
  }
}

With GraphQL, we can eliminate the guesswork and just describe the connections between the data to allow you to retrieve only the information you need.

Additionally, to directly answer your question, yes, with the REST API, you would have to do as you describe.

I hope that helps!

1 Like