Skip to main content

A python client for the GitHub API

Project description

GhApi

A delightful and complete interface to GitHub's amazing API

GhApi provides 100% always-updated coverage of the entire GitHub API. Because we automatically convert the OpenAPI spec to a Pythonic API, GhApi is always up to date with the latest changes to GitHub APIs. Furthermore, because this is all done dynamically, the entire package is only 35kB in size!

Using GhApi, you can do anything that you can do through the GitHub web interface or through the git client, such as:

Install

Either pip install ghapi or conda install -c fastai ghapi.

How to use

Throughout this documentation, you will see code inputs and outputs shown in this format:

1+1
2

We recommend reading the documentation on the official site, rather than on GitHub, since not all the functionality described on this page is available through the GitHub viewer.

All of the documentation is available directly as Jupyter Notebooks, for instance the current page you're reading is available as a notebook here. To open any page as an interactive notebook in Google Colab, click the Colab badge at the top of the page.

To access the GitHub API, first create a GhApi object:

api = GhApi()

Every part of the API includes documentation directly in the api object itself. For instance, here's how to explore the groups of functionality provided by the API by displaying the object:

api

Then we can explore the endpoints provided by the API in each group, e.g. for the git group:

api.git

Here's how to learn about an endpoint you want to use, e.g.:

api.git.get_ref

git.get_ref(owner, repo, ref): Get a reference

In Jupyter Notebook full tab completion, parameter lists, etc are provided for all endpoints. Endpoints are called as standard Python methods:

api.git.get_ref(owner='fastai', repo='fastcore', ref='heads/master')

For access to authenticated endpoints, pass a GitHub token. You can also pass any parameters you want auto-inserted into relevant methods, such as owner and repo:

api = GhApi(owner='fastai', repo='fastcore', token=github_token)

We can now repeat the previous method, but only need to pass ref:

api.git.get_ref('heads/master')

Now that we've provided our token, we can use authenticated endpoints such as creating an issue:

issue = api.issues.create("Remember to check out GhApi!")

Since we've now checked out GhApi, let's close this issue. 😎

api.issues.update(issue.number, state='closed')

Tab completion

You can enable tab completion for ghapi by placing the following command at the end of your ~/.bashrc or ~/.zshrc file:

eval "$(completion-ghapi --install)"

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

ghapi-0.1.5.tar.gz (43.5 kB view details)

Uploaded Source

Built Distribution

ghapi-0.1.5-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file ghapi-0.1.5.tar.gz.

File metadata

  • Download URL: ghapi-0.1.5.tar.gz
  • Upload date:
  • Size: 43.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200925 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.7

File hashes

Hashes for ghapi-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9e292e55d8907e17ccbe4f24d9f20d323c805a665099c49303aefe7c813a62bb
MD5 0133832f27ed707377a573a8b90dd34e
BLAKE2b-256 e1828f0b293b0ef5a157b3a8f2d15d248bc30aea1771d1fd7b78171db99de7c0

See more details on using hashes here.

File details

Details for the file ghapi-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: ghapi-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200925 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.7

File hashes

Hashes for ghapi-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4864a72ae500fe8b04568dd98ea49a0373b675246b23c0d042cc888edf20e65c
MD5 3664c97482a698fb394fdcea27d9aae9
BLAKE2b-256 46b3853399e11d04cbe0f0e4c034900c668b9df427cc965a478d638907e36f81

See more details on using hashes here.

Supported by

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