James Sugrue [asked][1], "@GitHubAPI is there a way to find the number of stars for a given repository?"
$ curl -ni "https://api.github.com/search/repositories?q=more+useful+keyboard" -H 'Accept: application/vnd.github.preview'
{
# Search for code containing the term "_cache" in repositories owned by @jasonrudolph | |
curl -G -H "Accept: application/vnd.github.preview.text-match" \ | |
https://api.github.com/search/code --data-urlencode "q=@jasonrudolph _cache" |
Let's have some command-line fun with curl, [jq][1], and the [new GitHub Search API][2].
Today we're looking for:
A curl example to help explain this Stack Overflow question related to creating a new branch via the GitHub Git Refs API:
curl -i https://api.github.com/repos/jasonrudolph/sandbox/git/refs/heads/master \
-H "Authorization: token REDACTED"
HTTP/1.1 200 OK
...
curl -H "Accept: application/vnd.github.v3.star+json" https://api.github.com/users/glaforge/starred |
curl https://api.github.com/repos/atom/atom/stargazers -H 'Accept: application/vnd.github.v3.star+json' |
Repository redirects are coming to the GitHub API, and this functionality is now available for developers to preview. Let's try it out.
First, we need a repository that has been renamed or relocated. Since jasonrudolph/jasonrudolph.github.io was previously named jasonrudolph/jasonrudolph.com, we can use it as our guinea pig. 🌍🐖
We'll use curl for all of our examples below, and we'll include the --location
option to instruct curl to follow any redirects that it encounters.
Using the current production version of the GitHub API, when we attempt to [access the repository](https://developer.github.com/v3/repos/#get
Sample timings using Heroku CI for a small-ish Rails 6 app on various Heroku dyno types:
Dyno Type | Run 1 Duration | Run 2 Duration | Run 3 Duration | Average Duration |
---|---|---|---|---|
standard-1x | 312 | 213 | 303 | 276 |
standard-2x | 227 | 121 | 222 | 190 |
performance-m | 162 | 164 | 175 | 167 |
performance-l | 100 | 104 | 107 | 104 |