I am trying to use GitHub graph API to make requests and grab only the details I require ie. number of stars on some public repo. An unauthenticated request to get details on a repo using V3 (REST) api works fine, but it contains a million details of the repo which I don't need, I just need number of stars on the repo.
When I make following request:
query {
repository(owner: "facebook", name: "react") {
stargazers {
totalCount
}
}
}
In javascript using fetch it responds 401 Unauthorized
fetch('https://api.github.com/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: '{ repository(owner: "facebook", name: "react") { stargazers(last: 10) { totalCount } } }' })
})
.then(res => res.json())
.then(res => console.log(res));
I need to show the data on a public website so I can't use a token from my GitHub account to authenticate.
Is there some way to make requests without authenticating, maybe some workaround. Or is it not possible?