상세 컨텐츠

본문 제목

github python API (PyGithub)

Development

by chbae 2023. 4. 21. 03:44

본문

728x90
반응형

PyGithub는 Github API를 Python에서 쉽게 호출하여 사용할 수 있게 만든 모듈이다.

 

설치는 $ pip install PyGithub로 간단하게 설치가 가능하다.

 

Example

Github API 사용을 위한 token을 생성하는 방법은 github 사이트에 접속해서 settings에 들어가면 아래와 같은 메뉴에서 진행하면된다.

 

다음은 private 저장소를 특정 조직에 생성하는 예제이다.

 #!/usr/bin/python  
 from github import Github  
 git = Github('chbae', 'token key 입력')  
 org = git.get_organization('조직 입력')  
 org.create_repo('저장소 이름', private=True)  
 for repo in org.get_repos():  
   print repo.name

 

Reference

728x90

관련글 더보기