How to get original forked repository with the github api? -


i wondering how original repository forked repositories.

i using https://api.github.com/users/:user/repos?type=forks list of forked repositories. returns various links on forks, cannot find how original repository.

any idea ?

note: else looping on https://api.github.com/users/:user/events

you can load list of forked repositories using endpoint mentioned:

curl https://api.github.com/users/:user/repos?type=forks 

which return following json feed (irrelevant informations omitted):

[   {     "id": 24328834,     "name": "repo_name",     "full_name": ":user/repo_name",     "owner": {     }     ...     "url": "https://api.github.com/repos/:user/repo_name",     ...   }   {     "id": 24328835,     "name": "repo_name_2",     "full_name": ":user/repo_name_2",     "owner": {       ...     }     ...     "url": "https://api.github.com/repos/:user/repo_name_2"     ...   } ] 

edited based on @jasonrudolph suggestions

then, out list returned, pull out repo_name under name element key , use construct repository url, or refer url element issue request against follows:

curl https://api.github.com/repos/:user/repo_name 

that in return give requested user repository informations (note simplest of queried urls) can retrieve:

  • the parent json element holds repository, issued 1 forked, informations including id / name / url...
  • the source json element holds original repository information, in case issued repository fork of fork.

something following (here parent nothing source, i.e. repository forked original one):

{   "id": 24328834,   "name": "repo_name",   "full_name": "user/repo_name",   "owner": {     ...   },   ...   "parent": {     "id": 354448,     "name": "repo_name",     "full_name": "real_owner_name/repo_name",     "owner": {       ...     }   }   "source": {     "id": 354448,     "name": "repo_name",     "full_name": "real_owner_name/repo_name",     "owner": {       ...     }   } } 

Popular posts from this blog