Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there possibility to get releases with pyGithub

I havent used PyGithub yet but I am just curious if there is any possibility to get a list of releases from a repository (e.g. https://github.com/{username}/{repo-name}/releases). I can not see any information about that in documentation here.

like image 703
widget Avatar asked Nov 07 '16 10:11

widget


2 Answers

The question is a bit old but nobody seems to have answered it in the way the OP asked.

PyGithub does have a way to return releases of a repo, here is a working example:

from github import Github

G = Github('')  # Put your GitHub token here
repo = G.get_repo('justintime50/github-archive')
releases = repo.get_releases()

for release in releases:
    print(release.title)

The above will return the following:

v4.3.0
v4.2.2
v4.2.1
v4.2.0
v4.1.1
...

I hope this is helpful!

like image 156
Justin Hammond Avatar answered Sep 28 '22 04:09

Justin Hammond


You can get a list of releases from a GitHub repo by making a GET request to

https://api.github.com/repos/{user}/{repo}/releases

Eg

import requests

url = 'https://api.github.com/repos/facebook/react/releases'
response = requests.get(url)

# Raise an exception if the API call fails.
response.raise_for_status()

data = response.json()

Also its worth noting you should be making authenticated requests otherwise you'll hit GitHubs API rate limiting pretty quickly and just get back 403s.

like image 33
Mat Avatar answered Sep 28 '22 05:09

Mat