Skip to main content

An advanced REST client for the GitHub API

Project description

GitHub Workflow Status Code Coverage Code Grade PyPI version

github3api

An advanced REST client for the GitHub API. It is a subclass of rest3client tailored for the GitHub API with special optional directives for GET requests that can return all pages from an endpoint or return a generator that can be iterated over. By default all requests will be retried if ratelimit request limit is reached.

Installation

pip install github3api

Example Usage

>>> from github3api import GitHubAPI

GitHubAPI instantiation

# instantiate using no-auth
>>> client = GitHubAPI()

# instantiate using a token
>>> client = GitHubAPI(bearer_token='****************')

GET request

# GET request - return JSON response
>>> client.get('/rate_limit')['resources']['core']
{'limit': 60, 'remaining': 37, 'reset': 1588898701}

# GET request - return raw resonse
>>> client.get('/rate_limit', raw_response=True)
<Response [200]>

POST request

>>> client.post('/user/repos', json={'name': 'test-repo1'})['full_name']
'soda480/test-repo1'

>>> client.post('/repos/soda480/test-repo1/labels', json={'name': 'label1', 'color': '#006b75'})['url']
'https://api.github.com/repos/soda480/test-repo1/labels/label1'

PATCH request

>>> client.patch('/repos/soda480/test-repo1/labels/label1', json={'description': 'my label'})['url']
'https://api.github.com/repos/soda480/test-repo1/labels/label1'

DELETE request

>>> client.delete('/repos/soda480/test-repo1')

GET all directive - Get all pages from an endpoint and return list containing only matching attributes

for repo in client.get('/user/repos', _get='all', _attributes=['full_name']):
    print(repo['full_name'])

GET page directive - Yield a page from endpoint

for page in client.get('/user/repos', _get='page'):
    for repo in page:
        print(repo['full_name'])

Projects using github3api

Development

Ensure the latest version of Docker is installed on your development server. Fork and clone the repository.

Build the Docker image:

docker image build \
--target build-image \
--build-arg http_proxy \
--build-arg https_proxy \
-t \
github3api:latest .

Run the Docker container:

docker container run \
--rm \
-it \
-e http_proxy \
-e https_proxy \
-v $PWD:/github3api \
github3api:latest \
/bin/sh

Execute the build:

pyb -X

NOTE: commands above assume working behind a proxy, if not then the proxy arguments to both the docker build and run commands can be removed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

github3api-0.0.9.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

github3api-0.0.9-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file github3api-0.0.9.tar.gz.

File metadata

  • Download URL: github3api-0.0.9.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.13

File hashes

Hashes for github3api-0.0.9.tar.gz
Algorithm Hash digest
SHA256 63ad64c74ca4afbaba378c58593bcf50b8ee6c4e2d9235d802ce86d6f351a526
MD5 b0f7efef471f0f5e21beff47ff58daa7
BLAKE2b-256 4584b0846bd9188d0ed269acdc336bc183ff1f0e88ca23d19765f1cecf7a8754

See more details on using hashes here.

File details

Details for the file github3api-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: github3api-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.13

File hashes

Hashes for github3api-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 23e51b00405fd77bd62f0cc28336ef186fbbcc72aa641d8000ba6673f364c0ac
MD5 845be3901ce778034771c9e58bb44192
BLAKE2b-256 47024db8458be516cdc8da555a7017f8e80f94e9e6ae7462f64c25791a9ac618

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page