LoginSignup
12
14

More than 5 years have passed since last update.

GitHub APIでPull Requestを取得する

Posted at

GitHub APIを使って色々してみようと思うので使い方についてのメモ。あくまでメモ。
現時点ではv3が最新のようです。

前提

GitHubで「Personal access tokens」からrepoに対して操作可能なTokenを取得しておく。
※追記:repo操作権限なくても大丈夫でした。

GitHub APIリファレンス

List pull requests(PRの一覧を取得)
Get a single pull request(個別PRを取得)

実行してみる

Pull Request一覧の取得

curl https://api.github.com/repos/kz800/hoge/pulls?access_token=xxxxx&state=open

個別のPull Requestの取得

curl https://api.github.com/repos/kz800/hoge/pulls/1?access_token=xxxxx&state=open

一旦これが動作するところまで確認できた。
パラメーターはAPIリファレンスにあるように他にもあるので試してみたい。

Tokenはリクエストヘッダに指定することも可能

curl -H "Authorization: token xxxxx" https://api.github.com/repos/kz800/hoge/pulls?state=open
12
14
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
12
14