3
1

More than 3 years have passed since last update.

pythonでgithub apiを呼び出してPull Request 情報を取得する

Last updated at Posted at 2020-03-17

背景

データ基盤のデータソースとなるサービスのレポジトリのスキーマ変更があった場合に自動で通知がくるような機能を作りたい。github api で Pull Request 情報を引っ張ってきて作ったのでその時のメモ。
認証は、個人アクセストークンを使用する↓

コマンドライン用の個人アクセストークンを作成する

実装


import requests

# closeされたPRのみ取得
URL = 'https://api.github.com/repos/owner/repo_name/pulls?&state=closed'
headers = {'Authorization': 'token xxxxx'} # 取得したアクセストークン
r = requests.get(URL.format(repo), headers=headers)
return r.json()

参考

3
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
3
1