Skip to main content

Easily create maintainable API clients.

Project description


Easily create maintainable API clients.


Building other Python based API clients I found that there was a tendency to end up with a "mega-class", containing most of the definitions of my API. BaseAPI tries to keep unrelated API concepts separate, hopefully making for an easier maintenance experience.


PyPi is the easiest way to install:

pip install base-api


Creating a client

Normally the Client class is inherited to create your own client class:

from baseapi import Client

class MyClient(Client):
    DEFAULT_URL = ''

Here we've set our default API URL. This can also be set during the creation of the client:

client = MyClient(url='https://localhost')

Creating APIs

To populate your client with functions to access your API use individual API classes. These reflect an isolated part of your overall API.

As an example, you may have an authorization component to your API. To add authorization to your client library, you may create a file called

from baseapi.apis import GraphqlApi

class AuthApi(GraphqlApi):
    def login(self, username, password):
        # TODO

    def logout(self):
        # TODO

Once you have this slice of your API ready, you can add it to your client by specifying it during the client class definition:

from baseapi import Client

class MyClient(Client):
    DEFAULT_URL = ''

In this case, must be placed in your PYTHONPATH, most likely alongside your client class file.

TODO: More to come...

Project details

Download files

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

Files for base-api, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size base-api-0.0.2.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page