We’ll start by seeing ghapi in action in Python using Jupyter Notebook. But first, let’s see what it looks like to actually use ghapi!
We even used it to help some other developers with their projects, including using it for GitHub CEO, Nat Friedman’s, ghtop project as part of a code overhaul that Nat described as a “ tour de force.” The “secret sauce” behind ghapi is GitHub’s new OpenAPI specification, a machine-readable catalog of every part of the GitHub API. We spent a lot of time using ghapi for our own projects to ensure that the developer experience is consistent, intuitive, and Pythonic. We built ghapi, a Python library and CLI tool, to resolve these challenges. Furthermore, Actions are run in a special environment, which can slow iteration and debug cycles.
However, this API only covers a small subset of the full API’s functionality. GitHub provides gh, a command line tool that integrates with GitHub, including access to some API functionality.Due to the size of the API, libraries generally do not provide full coverage and documentation for all API endpoints.
There are software libraries that make this easier, but each library only handles a subset of the full API, and each one has a whole new interface to learn. Debugging is difficult, because errors raise obscure HTTP status codes. Accessing HTTP APIs directly is clunky and requires careful study of every API endpoint.
I want to be able to type a single command to close a bunch of issues with a template response. For instance, I’d love to be able to see at a glance every issue or PR that someone has replied to or added since I last checked. That said, there’s lots of things I want to automate or customize for my workflows as a maintainer.
I use GitHub Actions to automate testing, build software, triage issues, and even to power whole projects, such as fastpages. I maintain dozens of repositories and respond to issues and pull requests every day. Like many developers, I spend a lot of time on GitHub. It includes tab-completion, integrated documentation, and many little touches to make your life easier, such as automatic pagination of responses, automatic management of all required headers, query strings, route parameters and post data, and much more. Summary : Today fast.ai is releasing ghapi, the first Python library and CLI to provide complete, idiomatic access to the entire GitHub API, using a consistent interface. Guest article by Jeremy Howard, founding researcher at fast.ai and lead developer of ghapi and Hamel Husain, Staff Machine Learning Engineer at GitHub and contributor to ghapi.