Reputation: 57
So, I have a get request:
https://api.github.com/users/exampleName/repos
This returns a list of json objects which are all the public repos this user has.
What if I want to get one of his specific repo by its full_name like
https://api.github.com/users/exampleName/repos/?full_name=exampleFull_name.
I tried this but it is not working.
I am not sure how to retrieve a specific Json object from a list in a api call.
Any help would be appreciated.
Upvotes: 1
Views: 1022
Reputation: 4808
If you already know the repo name, the URL for the request is:
https://api.github.com/repos/[user]/[repo]
Where [user]
is the repo owner's GitHub username, and [repo]
is the repo name.
Example:
https://api.github.com/repos/octocat/Hello-World
Upvotes: 1
Reputation: 116
If you know the username and repo directly. You can just generate the url:
https://api.github.com/repos/{username}/{reponame}
If you don't know the repo name, you'll have to perform multiple API queries.
First you need to get the list of public repos with:
https://api.github.com/users/exampleName/repos
Then you need to loop through all the repos and find the name that matches the one you want. For example you want the repo named ExampleRepository
. Once you get the repo object that matches what you want. You can get the url
for that repo.
[
{
...
"name": "ExampleRepository",
"url": "https://api.github.com/repos/ExampleName/ExampleRepository",
},
...
]
Upvotes: 2