I am wondering how to get the original repository from my forked repositories.
I am using https://api.github.com/users/:user/repos?type=forks
to get the li
You can load a list of the forked repositories using just the endpoint you mentioned:
curl https://api.github.com/users/:user/repos?type=forks
which will return something like the 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"
...
}
]
Then, out from the list returned, you pull out the repo_name under the name element key and use it to construct the repository url, or just refer to the url element to issue a GET request against as follows:
curl https://api.github.com/repos/:user/repo_name
that in return will give you the requested user repository informations (note that is the simplest of queried urls) from which you can retrieve:
Something like the following (here the parent is nothing but the source, i.e. the repository was forked from the 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": {
...
}
}
}