Skip to main content

Python client for GitHub API

Project description

Python client for GitHub API

Installation

Note octokit and octokit.py were already taken in the cheese shop

pip install octokitpy

Documentation

https://octokitpy.readthedocs.io/en/latest/

Examples

REST API:

from octokit import Octokit
repos = Octokit().repos.list_for_user(username="octokit")
for repo in repos.json:
    print(repo["name"])
# Make an unauthenticated request for octokit's public repositories

Webhooks:

from octokit import webhook
webhook.verify(headers, payload, secret, events=['push'])

octokit.py provides a function to verify webhooks sent to your application.

headers

dictionary of request headers

payload

string; payload of request

secret

string; secret provided to GitHub to sign webhook

events

list; events that you want to receive

verify_user_agent

boolean; whether or not you want to verify the user agent string of the request

return_app_id

boolean; whether or not you want to return the app id from the ping event for GitHub applications. This will only return the id if the event is the ping event. Otherwise the return value will be boolean.

Note that webhook names are available at from octokit_routes import webhook_names

Authentication

Instantiate a client with the authentication scheme and credentials that you want to use.

basic:

octokit = Octokit(auth='basic', username='myuser', password='mypassword')

token:

response = Octokit(auth='token', token='yak').authorization.get(id=100)

app:

octokit = Octokit(auth='app', app_id='42', private_key=private_key)

app installation:

octokit = Octokit(auth='installation', app_id='42', private_key=private_key)

For applications, provide the application id either from the ping webhook or the application’s page on GitHub. The private_key is a string of your private key provided for the application. The app scheme will use the application id and private key to get a token for the first installation id of the application.

API Schema/Routes/Specifications

One can instantiate the Octokit with routes=specification where the specification is one of api.github.com, ghe-2.15, etc.

Data

The octokit client based on the available route data and webhook data

TODOs

GitHub APIs

[-] REST (see best practices, integration tests, and errors)

[ ] GraphQL client

[x] GitHub Apps

[ ] OAuth Apps

[x] Webhooks

Tests

[x] unit tests

[ ] integration tests - need fixtures to assert against

[x] coverage uploaded to code climate

Errors

[ ] Raise `OctokitValidationError` for param validation error

[ ] Raise `OctokitAuthenticationError` for auth error

[ ] Raise `OctokitRateLimitError` for rate limiting errors

Best Practices

[ ] throttling

[ ] handles rate limiting

[x] pagination

Documentation

[ ] Auto generated documentation

Deployment

[x] Deploy wheels

[ ] GitHub releases

Check box guide

[ ] Incomplete

[-] Partially completed

[x] Completed

Development

To run the all tests run:

tox

Contributing

Pull requests are very welcome!

Please see CONTRIBUTING.md for more information.

Credits

Package based on cookiecutter-pylibrary

License

MIT

Changelog

0.13.0

Breaking changes

  • Change to OpenAPI specifications

  • Remove python 3.5 support

  • Remove caching of parameters between calls

  • Method parameters are typed checked to the OpenAPI schemas

0.1.0 (?)

  • First release on PyPI.

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

octokitpy-0.14.1.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

octokitpy-0.14.1-py2.py3-none-any.whl (9.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file octokitpy-0.14.1.tar.gz.

File metadata

  • Download URL: octokitpy-0.14.1.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for octokitpy-0.14.1.tar.gz
Algorithm Hash digest
SHA256 644351b782bd53966f545fe0250c4488ad14d96d71fbf2b073e0c0c477316004
MD5 f1edb92d4bbba8b960c51e7c5d786500
BLAKE2b-256 ef141dadd9a13626f8d0679577537c7f6411b3ea53b108801768586e019dea11

See more details on using hashes here.

File details

Details for the file octokitpy-0.14.1-py2.py3-none-any.whl.

File metadata

  • Download URL: octokitpy-0.14.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for octokitpy-0.14.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9c06a94a7c7e60f3ce64d504581061ad470b3c1291f28165334e353e3e673641
MD5 2c13cbd18c951d4d8a3c665434d5f8f0
BLAKE2b-256 62c19b1dd458187fcffbefe069851c72ff6c05a9008f48cd8e2c2af91aee6390

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