Python wrapper for GitHub API v3

Overview

https://secure.travis-ci.org/copitux/python-github3.png

Pygithub3

Pygithub3 is a wrapper to the Github API v3, written in Python.

It has been developed with extensibility in mind, because the API is in a beta state, trying to achieve a very loosly coupled software.

It should be very easy to extend to support new requests and resources, because each of them are managed by itself.

Pygithub3 docs

Github API v3 docs

Fast install

pip install pygithub3

Fast example

from pygithub3 import Github

gh = Github(login='copitux', password='password')

copitux = gh.users.get()
kennethreitz = gh.users.get('kennethreitz')

copitux_repos = gh.repos.list().all()
kennethreitz_repos = gh.repos.list('kennethreitz').all()

Achievements

TODO

  • Oauth authorization API (service?)
  • Proxy methods into resources (e.g copitux.followers)

Contribute

  1. Fork the repository
  2. Write a test to cover new feature or to reproduce bug
  3. Code with pep8 rules
  4. Add yourself to AUTHORS
  5. Pull request it to develop branch

Tests

Run make init to install test requirements and nosetests to run tests.

Comments
  • Don't use SSLv3

    Don't use SSLv3

    We have recently disabled support for SSLv3 at GitHub, as it is a very old version of the SSL protocol that is now also known to be vulnerable:

    http://googleonlinesecurity.blogspot.com/2014/10/this-poodle-bites-exploiting-ssl-30.html https://www.imperialviolet.org/2014/10/14/poodle.html

    We have had several reports from GitHub users using the Pygithub3 library, complaining of failing requests due to the use of SSLv3 in the library. Here's an example traceback that has been reported:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/Users/ray/virtualenv/pygh3/lib/python2.7/site-packages/pygithub3/services/users/__init__.py", line 36, in get
    return self._get(request)
    File "/Users/ray/virtualenv/pygh3/lib/python2.7/site-packages/pygithub3/services/base.py", line 142, in _get
    response = self._client.get(request, **kwargs)
    File "/Users/ray/virtualenv/pygh3/lib/python2.7/site-packages/pygithub3/core/client.py", line 83, in get
    response = self.request('get', request, **kwargs)
    File "/Users/ray/virtualenv/pygh3/lib/python2.7/site-packages/pygithub3/core/client.py", line 70, in wrapper
    return func(self, verb, request, **kwargs)
    File "/Users/ray/virtualenv/pygh3/lib/python2.7/site-packages/pygithub3/core/client.py", line 76, in request
    response = self.requester.request(verb, request, **kwargs)
    File "/Users/ray/virtualenv/pygh3/lib/python2.7/site-packages/requests/sessions.py", line 252, in request
    r.send(prefetch=prefetch)
    File "/Users/ray/virtualenv/pygh3/lib/python2.7/site-packages/requests/models.py", line 632, in send
    raise SSLError(e)
    requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol
    

    /cc @copitux

    opened by jdennes 6
  • Update requests requirement with API changes.

    Update requests requirement with API changes.

    We're currently having conflicts with the requests requirement because it's pinned to an old version. Tests are passing after making a couple small changes where the requests API has changed.

    Related to #33.

    opened by conorbranagan 5
  • Incompatible with Requests 0.14.0

    Incompatible with Requests 0.14.0

    It looks like something in Requests 0.14.0 (maybe ealier, I've been using 0.13.2) has broken the way python-github3 handles session params.

    Creating a Github object fails with the following traceback:

    Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import requests
    >>> requests.__version__
    '0.14.0'
    >>> from pygithub3 import Github
    >>> gh = Github()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "pygithub3/github.py", line 24, in __init__
        self._users = User(**config)
      File "pygithub3/services/users/__init__.py", line 14, in __init__
        self.keys = Keys(**config)
      File "pygithub3/services/base.py", line 44, in __init__
        self._client = Client(**config)
      File "pygithub3/core/client.py", line 29, in __init__
        self.__set_params(self.config)
      File "pygithub3/core/client.py", line 56, in __set_params
        self.requester.params['per_page'] = config.get('per_page')
    TypeError: list indices must be integers, not str
    
    opened by bradmontgomery 4
  • Issues service

    Issues service

    Like I wrote in the previous pull request I've continued working after @conorbranagan's commits. I've added the Label and Milestone services into Issues.

    opened by ghost 4
  • create_gist() again

    create_gist() again

    Here's the create_gist() method re-implemented on top of the current head of your develop branch.

    I also created some unit tests for the gist functionality and revised the usage example in the readme file.

    opened by akaihola 3
  • Updated Library to work with Github api changes

    Updated Library to work with Github api changes

    Updated api in regards to recent changes to watching and stargazing api's, (these are subject to change with github's current phased transition http://developer.github.com/changes/2012-9-5-watcher-api/)

    Also added rate limiting increase by supplying oauth client id and client secret due to http://developer.github.com/changes/2012-10-14-rate-limit-changes/

    opened by oracal 2
  • Add travis-ci.org configuration file

    Add travis-ci.org configuration file

    A simple patch to add support for Travis CI. Just follow getting started guide[1] to enable it.

    [1] http://about.travis-ci.org/docs/user/getting-started/

    Signed-off-by: Paul Belanger [email protected]

    opened by pabelanger 2
  • What to do about api changes?

    What to do about api changes?

    I used the api and I noticed some slight changes from the documentation. What should I do about it? Are you still working on it and would you like some help?

    opened by kivo360 1
  • Support for requests>0.14

    Support for requests>0.14

    requests 0.14 is too old and it's bad to set version so strictly anyway. In requests >0.14.0 self.params became a dict so I do a few changes and fix dependency version. I run tests for requests 1.2.3 and requests 2.3.0 and everything seems to be ok.

    opened by Kagami 1
  • requests version in requirements/base.txt conflicts with version requests of requests installed before install pygithub3

    requests version in requirements/base.txt conflicts with version requests of requests installed before install pygithub3

    requests version in requirements/base.txt conflicts with version requests of requests installed before install pygithub3.

    This does not create an issue when using in code. But the setuptools implementation of creating CLI tools using entry_points.console_scripts raises an error whenever there is a mismatch between the installed package version and the one required by any other package that the console_script makes use of. Debugging this becomes a pain because setuptools just throws an error about the version mismatch and not the package which requires that particular version.

    To my knowledge, this package works fine with the newer version of requests. I did not run tests thought.

    opened by vaidik 1
  • Added support for the OAuth Authorizations API

    Added support for the OAuth Authorizations API

    This adds support for the OAuth Authorizations API (http://developer.github.com/v3/oauth/#oauth-authorizations-api). This is particularly useful because you can now create an OAuth Token without implementing the web flow (discussed in this blog post: http://developer.github.com/changes/2012-12-06-create-authorization-for-app/)

    opened by bradmontgomery 1
  • Adding a collaborator to a repo returns pygithub3.exceptions.BadRequest: 400 - Problems parsing JSON

    Adding a collaborator to a repo returns pygithub3.exceptions.BadRequest: 400 - Problems parsing JSON

    I'm trying to add a collaborator to a repo with:

    gh.repos.collaborators.add("collaborator-name", "name", "repo")
    

    but I'm getting:

    pygithub3.exceptions.BadRequest: 400 - Problems parsing JSON
    

    Here is the full stack:

    Traceback (most recent call last):
      File "./test.py", line 8, in <module>
        collaborators = gh.repos.collaborators.add("collaborator-name", "name", "repo")
      File "/Library/Python/2.7/site-packages/pygithub3/services/repos/collaborators.py", line 40, in add
        return self._put(request)
      File "/Library/Python/2.7/site-packages/pygithub3/services/base.py", line 129, in _put
        response = self._client.put(request, data=input_data, **kwargs)
      File "/Library/Python/2.7/site-packages/pygithub3/core/client.py", line 100, in put
        response = self.request('put', request, **kwargs)
      File "/Library/Python/2.7/site-packages/pygithub3/core/client.py", line 71, in wrapper
        return func(self, verb, request, **kwargs)
      File "/Library/Python/2.7/site-packages/pygithub3/core/client.py", line 81, in request
        GithubError(response).process()
      File "/Library/Python/2.7/site-packages/pygithub3/core/errors.py", line 35, in process
        raise raise_error()
      File "/Library/Python/2.7/site-packages/pygithub3/core/errors.py", line 23, in error_400
        raise BadRequest("400 - %s" % self.debug.get('message'))
    pygithub3.exceptions.BadRequest: 400 - Problems parsing JSON
    

    I tried deleting and listing, they both work fine, but adding doesn't work. Could you please advice? Thanks.

    opened by hhebbo 0
  • How to get the latest release of a repository?

    How to get the latest release of a repository?

    I try to get the latest release of a repository but i cant figure out how to correctly do this with python-github3?

    i know hot to get all the releases and i think that the first of them may be always the latest but is this true and how can i be sure?

    latest_release = None
    releases = online_repo.releases()
    for release in releases:
        latest_release = release
        break
    

    Just like in: GET /repos/:owner/:repo/releases/latest https://developer.github.com/v3/repos/releases/#get-the-latest-release

    opened by michaelkarrer81 0
  • How to set proxies?

    How to set proxies?

    I wrote my test code as follows:

    from pygithub3 import Github
    proxies = {"http": "http://<ip>:<port>", "https": "http://<ip>:<port>", }
    gh = Github(login=<userID>, password=<userPWD>, token=<OAUTH-TOKEN>, proxies = proxies)
    use = gh.users.get(<userID>)
    

    Which raise:

      File "/my/path/to/test/code/v1.py", line 10, in <module>
        octocat = gh.users.get()
      File "/usr/local/lib/python2.7/dist-packages/pygithub3/services/users/__init__.py", line 36, in get
        return self._get(request)
      File "/usr/local/lib/python2.7/dist-packages/pygithub3/services/base.py", line 143, in _get
        response = self._client.get(request, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/pygithub3/core/client.py", line 84, in get
        response = self.request('get', request, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/pygithub3/core/client.py", line 71, in wrapper
        return func(self, verb, request, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/pygithub3/core/client.py", line 77, in request
        response = self.requester.request(verb, request, **kwargs)
      File "/my/path/anaconda2/lib/python2.7/site-packages/requests/sessions.py", line 475, in request
        resp = self.send(prep, **send_kwargs)
      File "/my/path/anaconda2/lib/python2.7/site-packages/requests/sessions.py", line 585, in send
        r = adapter.send(request, **kwargs)
      File "/my/path/anaconda2/lib/python2.7/site-packages/requests/adapters.py", line 467, in send
        raise ConnectionError(e, request=request)
    requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /user?access_token=<OAUTH-TOKEN>&per_page=100 (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f4cbf2fb890>: Failed to establish a new connection: [Errno -5] No address associated with hostname',))
    

    I tried link https//api.github.com/user?access_token=<OAUTH-TOKEN>&per_page=100 with requests like:

    import requests   
    proxies = { "http": "http://<IP>:<PORT>", "https": "http:<IP>:<PORT>", }   
    a = requests.get("https://api.github.com/user?access_token=<AOTH-TOKEN>&per_page=100", proxies=proxies)  
    for key, value in a.__dict__.items():
        print key, ":", value
    

    It works.

    When I debug the first section of code described as above, I found an problem:

    When run the gh = Github(login=<userID>, password=<userPWD>, token=<OAUTH-TOKEN>, proxies = proxies), gh._users._client.config contains the params what I assigned. But when run the gh.users.get() the gh.users._client.config={}.

    Could anyone tell me how to set proxies?

    opened by YMMS 1
  • fixed problem with post for fork creation

    fixed problem with post for fork creation

    Fork creation fails with Github API v3, because it returns a status code 202 Accepted:

    https://developer.github.com/v3/repos/forks/

    This PR fixes the client post method. It is now accepting both 201 and 202 status codes.

    opened by luiscruz 0
Owner
David Medina
Developer [Py, Go]
David Medina
The Github repository for the Amari API wrapper.

Amari.py Amari.py is an async, easy to use API wrapper for the AmariBot. Installation Enter any of these commands to install the library: pip install

TheF1ng3r 5 Dec 19, 2022
Aws-lambda-requests-wrapper - Request/Response wrapper for AWS Lambda with API Gateway

AWS Lambda Requests Wrapper Request/Response wrapper for AWS Lambda with API Gat

null 1 May 20, 2022
A github actions + python code to extract URLs to code repositories to put into standard form, starting with github

A github actions + python code to extract URLs to code repositories to put into standard form, starting with github ---- NOTE: JUS

Justin Gosses 2 Nov 15, 2021
GitHub Activity Generator - A script that helps you instantly generate a beautiful GitHub Contributions Graph for the last year.

GitHub Activity Generator A script that helps you instantly generate a beautiful GitHub Contributions Graph for the last year. Before ?? ?? ?? After ?

null 1 Dec 30, 2021
Github-Checker - Simple Tool To Check If Github User Available Or Not

Github Checker Simple Tool To Check If Github User Available Or Not Socials: Lan

ميخائيل 7 Jan 30, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
Automation that uses Github Actions, Google Drive API, YouTube Data API and youtube-dl together to feed BackJam app with new music

Automation that uses Github Actions, Google Drive API, YouTube Data API and youtube-dl together to feed BackJam app with new music

Antônio Oliveira 1 Nov 21, 2021
Python API wrapper around Trello's API

A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object. The attributes of these objects

Richard Kolkovich 904 Jan 2, 2023
Async ready API wrapper for Revolt API written in Python.

Mutiny Async ready API wrapper for Revolt API written in Python. Installation Python 3.9 or higher is required To install the library, you can just ru

null 16 Mar 29, 2022
A Python API wrapper for the Twitter API!

PyTweet PyTweet is an api wrapper made for twitter using twitter's api version 2! Installation Windows py3 -m pip install PyTweet Linux python -m pip

TheFarGG 1 Nov 19, 2022
Python API wrapper library for Convex Value API

convex-value-python Python API wrapper library for Convex Value API. Further Links: Convex Value homepage @ConvexValue on Twitter JB on Twitter Authen

Aaron DeVera 2 May 11, 2022
This an API wrapper library for the OpenSea API written in Python 3.

OpenSea NFT API Python 3 wrapper This an API wrapper library for the OpenSea API written in Python 3. The library provides a simplified interface to f

Attila Tóth 159 Dec 26, 2022
YARSAW is an Async Python API Wrapper for the Random Stuff API.

Yet Another Random Stuff API Wrapper - YARSAW YARSAW is an Async Python API Wrapper for the Random Stuff API. This module makes it simpler for you to

Bruce 6 Mar 27, 2022
EpikCord.py - This is an API Wrapper for Discord's API for Python

EpikCord.py - This is an API Wrapper for Discord's API for Python! We've decided not to fork discord.py and start completely from scratch for a new, better structuring system!

EpikHost 28 Oct 10, 2022
A simple Python API wrapper for Cloudflare Stream's API.

python-cloudflare-stream A basic Python API wrapper for working with Cloudflare Stream. Arbington.com started off using Cloudflare Stream. We used the

Arbington 3 Sep 8, 2022
Discord-Wrapper - Discord Websocket Wrapper in python

This does not currently work and is in development Discord Websocket Wrapper in

null 3 Oct 25, 2022
An API wrapper around the pythonanywhere's API.

pyaww An API wrapper around the pythonanywhere's API. The name stands for pythonanywherewrapper. 100% api coverage most of the codebase is documented

null 7 Dec 11, 2022
An API Wrapper for Gofile API

Gofile2 from gofile2 import Gofile g_a = Gofile() print(g_a.upload(file="/home/itz-fork/photo.png")) An API Wrapper for Gofile API. About API Gofile

I'm Not A Bot #Left_TG 16 Dec 10, 2022