Github API documentation give instructions to filter repositories by topics. Is there a way to use the API to get the topics from a specific repo?
To search for a specific file or content within a repository, you can use the file finder or code-specific search qualifiers. For more information, see "Finding files on GitHub" and "Searching code." octocat in:readme matches repositories mentioning "octocat" in the repository's README file.
Use git fetch to retrieve new work done by other people. Fetching from a repository grabs all the new remote-tracking branches and tags without merging those changes into your own branches. Otherwise, you can always add a new remote and then fetch. For more information, see "Managing remote repositories."
To get the list of random users, you have to make a request to the /user endpoint, and to get the details of a specific user, you make a request to the /user/{username} endpoint. You can try out the following commands quickly in your terminal with curl to see the results.
You can do this easily with Github API (it's currently in "preview mode"):
curl -H "Accept: application/vnd.github.mercy-preview+json" https://api.github.com/repos/twbs/bootstrap/topics
{
"names": [
"css",
"bootstrap",
"javascript",
"html",
"jekyll-site",
"scss",
"css-framework",
"sass"
]
}
You need to include extra header Accept: application/vnd.github.mercy-preview+json
.
There is one "but", since it's in "preview mode" it's not supported for production use (please read "Note" and "Warning" sections in link below).
See also:
I don't know that there is a way to just get the topics for a repository, but if you do a get for a repository, the repository json object that is returned will have a topics property that is an array of that repositories topics.
At the top of that page of documentation, you will notice that in order to have the topics returned you will need to add a specific header in your GET
request: "Accept":"application/vnd.github.mercy-preview+json"
Hope this helps!
You can do this with the Github GraphQL API
Query:
{
repository(owner: "twbs", name: "bootstrap") {
repositoryTopics(first: 10) {
edges {
node {
topic {
name
}
}
}
}
}
}
This will return the first 10 topics and the name for each as shown below.
Response:
{
"data": {
"repository": {
"repositoryTopics": {
"edges": [
{
"node": {
"topic": {
"name": "css"
}
}
},
{
"node": {
"topic": {
"name": "bootstrap"
}
}
},
{
"node": {
"topic": {
"name": "javascript"
}
}
},
{
"node": {
"topic": {
"name": "html"
}
}
}
]
}
}
}
}
Test it out in the GitHub GraphQL Explorer
I added the fetch with Accept Headers:
fetch("https://api.github.com/users/lucksp/repos",
{
method: "GET",
headers: {
Accept: "application/vnd.github.mercy-preview+json"
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With