Skip to main content

The Elegant and Readable General API Library

Project description


Ever dealt with a bunch of API clients? Whether they be methods in your own code, or an abundance of external libraries, dealing with multiple APIs in one application can get messy.

ergal, the Elegant and Redable General API Library, is the solution to your API client problems. By using API profiles stored in a lightweight SQLite database, the user can access any API with ease by supplying just a few key details.


  • Abstract API handling
  • Clean up codebases
  • Win

Standard Installation

pip install ergal



Profile Creation

Before we can access an API (we'll use in this case), we have to add an API Profile. To create an API profile, we'll use the Profile class from ergal.profile.

>>> from ergal.profile import Profile
>>> profile = Profile('HTTPBin', base='')

A new row has been created in the local ergal.db database to house the API profile's information.

Now that the profile has been created, we'll need to add an endpoint, and to do so, we'll use the add_endpoint method, and supply it with a name, path, and method.

>>> profile.add_endpoint('Get JSON', '/json', 'get')
Endpoint 'Get JSON' for HTTPBin added at ab0b5ffa9fa95c6.

With an endpoint added, we can make the call. To do that, we'll use the call method. All we need to supply is the name of the endpoint we just added, and ergal will do the rest.

>>>'Get JSON')
<big dict of response data>

Hooray! Now we can do whatever we want with our cleaned up and easy-to-work-with dictionary of response data.


The biggest priority of this project is to make API handling simple, both on the client's side and ergal's side. That said, some protocol can get pretty complex. We've got a few major improvements on our roadmap, and contribution is always appreciated.

As per most open source projects, submitted code needs to be continuous with the rest in style, it needs to be as succinct and readable as it can be, and it has to serve a real purpose according to the objectives of this project.

Feature Ideas

OAuth 1.0a and OAuth 2

OAuth 2 is obviously the priority here, given its increase in popularity, however, we want to provide as much compatability as possible. ergal is supposed to be a one-stop solution!

Useful HTML Parsing

Though virtually every API uses JSON or XML to send response data, what may be useful is the parsing of HTML in the context of a scraping library. In the same sense, often times lots of code needs to be written to support scrapers of multiple sites, so having HTML compatability would be useful.

Targetted Parsing (being implemented in v0.1.7)

One of the original feature ideas for ergal was the targetted parsing of responses, i.e. one could specify on a given endpoint what data should be returned. This would, of course, further eliminate what parsing needs to be done on the client's end by abstracting it within ergal.

Response Analytics and Caching

This feature would enable the user to store the contents of responses in the local ergal.db database, as well as record analytical data about the activity of a given endpoint or API, i.e. number of calls, status codes, load times, etc.

Development Setup

git clone
cd ergal
pyenv local 3.7.1
poetry install

Development Requirements

Recommended Tools

  • pyenv (preferred venv manager)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
ergal-0.1.7-py3-none-any.whl (12.1 kB) Copy SHA256 hash SHA256 Wheel py3
ergal-0.1.7.tar.gz (5.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page