LoginSignup
10
1

More than 5 years have passed since last update.

GitHub のスターされた日付を取得したい

Posted at

GitHub のスターがつけられた日付を取得したい場合には Accept ヘッダーが必要。

# これでは取得できない
$ curl https://api.github.com/repos/ma2gedev/power_assert_ex/stargazers

# こうすると starred_at で取得できるようになる
$ curl -H 'Accept: application/vnd.github.v3.star+json' https://api.github.com/repos/ma2gedev/power_assert_ex/stargazers

公式にレスポンス結果もあるので、そっち見た方が早いです。

Octokit を使ってリポジトリにつけられた星を取得する

ruby の GitHub API クライアントである Octokit を使って日付つきのスターを獲得する方法をメモしておく。

$ bundle init
$ echo "gem 'octokit'" >> Gemfile
$ bundle install --path vendor/bundle
$ bundle console
irb(main):001:0> stargazers = Octokit.stargazers 'ma2gedev/power_assert_ex', accept: 'application/vnd.github.v3.star+json', per_page: 100
# あとはお好きに

SEE ALSO

10
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
1