Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 2

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

Solved! Go to Solution.

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? :)

 

 

thanks

1 Reply
Solution
Community Manager
Message 2 of 2

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

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!