Skip to content

Agnostic API classes for Python Requests · mirrored from https://gitlab.com/notpushkin/arequests

License

Notifications You must be signed in to change notification settings

notpushkin/arequests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agnostic Requests

Heavily inspired by agithub. Powered by Requests.

Usage

Let's make a GitHub API client.

from arequests import API

class Github(API):
    base_url = "https://api.github.com"

    def __init__(self, auth):
        super(Github, self).__init__()
        # self.session is a requests.Session [1] object here
        self.session.auth = auth
        self.session.headers.update({
            'Accept': 'application/vnd.github.v3+json'
        })

[1]: http://docs.python-requests.org/en/latest/user/advanced/#session-objects

>>> g = Github(("iamale", "f2a3ec8e7901edef12b6ce9bce437780b69a5cd3"))
>>> g.users["mdo"].get().json()
{
    'name': 'Mark Otto',
    'login': 'mdo',
    'blog': 'http://mdo.fm',
    'followers': 9388,
    'hireable': True,
    'site_admin': True,
    ...
}
>>> g.issues.get(params={"filter": "mentioned"}).json()
[{
    'id': 12345678,
    'repository': { ... },
    'number': 9,
    'state': 'open',
    'title': 'Propose a new schema',
    'body': ...,
    'comments': 6,
    ...
}, ...]

Releases

No releases published

Packages

No packages published

Languages