import github gh = github.Github(access_token) user = gh.get_user() repo = user.create_repo('new-repo')
import requests url = "https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}" response = requests.get(url.format(owner="owner_name", repo="repo_name", pull_number=7)) data = response.json() print("Title:", data['title']) print("Author:", data['user']['login']) print("Body:", data['body'])
import github gh = github.Github(access_token) repo = gh.get_repo("owner_name/repo_name") for issue in repo.get_issues(): print(issue.number, issue.title, issue.user.login)
import requests url = "https://api.github.com/search/repositories" params = {"q": "python", "sort": "stars"} response = requests.get(url, params=params) data = response.json() for repo in data['items']: print(repo['full_name'], repo['html_url'], repo['description'])Package/library: `requests` In conclusion, these examples use different Python libraries to interact with GitHub API to automate various tasks related to GitHub. The most common Python library used for GitHub API integration is `PyGithub`, but some tasks can also be accomplished using other libraries such as `requests`.