Skip to main content

Overview

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.

Metadata

Release files for octokitpy 0.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for octokitpy 0.15.0
File Size Uploaded
octokitpy-0.15.0.tar.gz 25.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for octokitpy 0.15.0
File Interpreter ABI Platform
octokitpy-0.15.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 35.1 kB

Release files / octokitpy-0.15.0.tar.gz

Download URL octokitpy-0.15.0.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0879c0e54dbd31aa304184d662ff09f543dafcd74e66fdf493063c77445ce57e
BLAKE2b-256 checksum
How to use checksums
2718a8de0efe370dc6ce79d3543b7f3dd5d5ce8e524de9e197d1ee70cc9d5a26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release files / octokitpy-0.15.0-py2.py3-none-any.whl

Download URL octokitpy-0.15.0-py2.py3-none-any.whl
Size 9.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
94acfa7d5384f0e0293c409ca3ed37c34cd06658c9f5389dea02bb6f175f531f
BLAKE2b-256 checksum
How to use checksums
85c79a3c2ab53634d285aee1c6c6d9557fab183c3acbfaf19f51900d19cafcd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.15.0 This release

2 release files

0.14.3

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

1 release file

0.4.1

2 release files

0.3.0

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page