An advanced REST client for the GitHub API
Project description
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 repo in client.get('/user/repos', _get='page'):
print(repo['full_name'])
Projects using github3api
-
edgexfoundry/sync-github-labels A script that synchronizes GitHub labels and milestones
-
edgexfoundry/prune-github-tags A script that prunes GitHub pre-release tags
-
edgexfoundry/create-github-release A script to facilitate creation of GitHub releases
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for github3api-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89194d7c9df5ebb1c42df846c877eac2681b010cb22e611416cf6a6b25293f4b |
|
MD5 | b77eb8c40ae89a70d1b37fdfc7fede4f |
|
BLAKE2b-256 | 99e85196caf713f66ae4b1ef8cb341fdf0c128db41fdf3f8755a5905370d61fc |