How to Star a Repo with Github API

How can I deal with a star a repository error with GitHub api?

It looks like you tried to attach your owner and repository as query parameters.

If you are referring to this API call (PUT /user/starred/{owner}/{repo}), then you need to include them as positional parameters instead. Update your url:

let url = URL(string: 
"https://api.github.com/user/starred/\(repoModel.ownerName)/\(repoModel.repoName)"
);

GitHub API: Number of Stars of a Repository Over Time

You can get the property starred_at using this custom media :

Accept: application/vnd.github.v3.star+json

Your headers might look something like this (I'm using Javascript here):

headers: {
...
Accept: 'application/vnd.github.v3.star+json',
...
},

See the documentation here: https://developer.github.com/v3/activity/starring/#alternative-response-with-star-creation-timestamps

This repository: https://github.com/timqian/star-history uses this technique to retrieve the stars over time to create a chart.

Using github api fetch number of stars overtime of a repository in python

I guess you forgot to add something in header (application/vnd.github.v3.star)

repo_response = requests.get(url,headers={'Accept': 'application/vnd.github.v3.star+json'})

Starring a repository with the github API

The problem here is the parameters you pass to urljoin(). The first parameter is supposed to be an absolute URL, while the second parameter is a relative URL. urljoin() then creates an absolute URL from that.

Also, "user" in this case is supposed to be a literal part of the URL, and not the username.

In this case, I would forgo the urljoin()-function completely, and instead use simple string substitution:

url = 'https://api.github.com/user/starred/{owner}/{repo}'.format(
owner=GITHUB_USER,
repo=GITHUB_REPO
)

Get n repositories with most stars out of a given organization - Github API

You can use the search API, specify your org and sort by stars:

https://api.github.com/search/repositories?q=org:YOUR_ORGg&sort=stars&order=desc

Example: https://api.github.com/search/repositories?q=org:mui-org&sort=stars&order=desc

You can limit to the top X repo using per_page (if X < 100). For instance to get the top 3 repo with most stars in the org mui-org:

https://api.github.com/search/repositories?q=org:mui-org&sort=stars&order=desc&per_page=3



Related Topics



Leave a reply



Submit