Skip to main content

The Elegant and Readable General API Library

Project description

ERGAL

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.

Goals

  • Abstract API handling
  • Clean up codebases
  • Get money

Standard Installation

pip install ergal

Requirements

Quickstart

Profile Creation

Before we can access an API (we'll use jsonplaceholder 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('JSON Placeholder API', base='https://jsonplaceholder.typico.com')

A new row has been created in the local ergal.db database file 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('list posts', '/posts', 'get')
Endpoint 'list posts' for JSON Placeholder API added at ab0b5ffa9fa95c61723d46ed82cbcf95.

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.

>>> profile.call('list posts')
{big dict of response data}

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

Contribution

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!

HTML

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

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.

Development Setup

git clone https://github.com/elliott-maguire/ergal
cd ergal
pyenv local 3.7.1
poetry install

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.5-py3-none-any.whl (18.6 kB) Copy SHA256 hash SHA256 Wheel py3
ergal-0.1.5.tar.gz (6.2 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