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
Unsafemutablepointer<Void> to Concrete Object Type
Timer Onreceive Not Working Inside Navigationview
How to Replace Limited Number of Occurrences in String
How to Make Swiftui Uiviewrepresentable View Hug Its Content
Swift Conditional Conformances with Generic Type
Getting an Issue with Upgrade to Xcode 10.2
Unknown Error When Adding an CSSearchableitem to Core Spotlight (Macos)
How to Implement a Swift Protocol Across Structs with Conflicting Property Names
How to Sort JSON Coming from Alamofire and Return Final JSON Object (Swiftyjson)
How to Test an Optionset with a Switch Statement
Safari App Extension Crashes After a Few Seconds for Hello World Project
Firebase References Undeclared
Is This Safe to Call Wait() of Dispatchsemaphore Several Times at One Time