파이썬(Python)에서 Github와 상호작용(Interaction) 처리

 

PyGithub 라이브러리 활용하기

PyGithub 라이브러리 활용하기 Github와 상호작용을 할 때 Github Rest API를 사용하는 방법도 있지만, PyGithub 라이브러리를 활용하면 더 쉽고 간단한 코드를 만들 수 있다. 파이썬 코드상에서 Github 를 관리할 수 있게 해준다. 예를들어 Repository, User Profile, Organization 등이 가능하다.

설치

pip install pygithub

예시

from github import Github

g = Github("user", "password")
g = Github("access_token")
g = Github(base_url="https://{hostname}/api/v3", login_or_token="access_token")
for repo in g.get_user().get_repos():
    print(repo.name)

문서

PyGithub Documentation를 참고하면 Repository 가져오기부터 여러가지 Interaction의 예시를 확인할 수 있다.

참고사항

PyGithub는 기본적으로 파이썬(2와 3)으로 동작하는 라이브러리이며 Github Rest API v3Github Enterprise API v3에 접근하여 작동한다.

이 글의 저작권은 Attribution-NonCommercial 4.0 International 라이센스를 따릅니다. Attribution-NonCommercial 4.0 International