Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Boilerplate-free way for creating libs for REST APIs

Project description

Build Status

REST API lib creator

REST API lib creator is a boilerplate-free way for creating libs for RESTful APIs (specially the ones created using Django REST framework - but certainly adaptable for other frameworks).


  • This is a port for a personal project I made for myself. It may or may not solve your needs (it solves mine).
  • This is still alpha. I opened this on GH just so I can see if this is something I should improve (or not).


pip install rest-api-lib-creator


  • The bare minimum for creating your own lib:
from rest_api_lib_creator.core import ViewsetRestApiLib

class User(ViewsetRestApiLib):
    base_api_url = ''
  • With this you can play around with your API:
users = User.list()  # Triggers a requests.get with url=
isinstance(users[0], User)

user = User.create(first_name='Filipe', last_name='Waitman', email='', photo=open('image.png', 'rb'))  # Triggers a with url= and data={'first_name': 'Filipe', 'last_name': 'Waitman', 'email': ''} and files={'photo': <file binary content>}

# Similarly to the call above you could create an empty object and save it:
user = User()
user.first_name = 'Filipe'
user.last_name = 'Waitman' = '' = open('image.png', 'rb')  # Triggers a with url= and data={'first_name': 'Filipe', 'last_name': 'Waitman', 'email': ''} and files={'photo': <file binary content>}

isinstance(user, User)
print(  # Prints the user id (assuming the API returned this field)
print(user.first_name)  # )rints the user first name (assuming the API returned this field)
user.first_name = 'New name'  # Triggers a requests.patch with url=<user-id> and data={'first_name': 'New name'}

user.delete()  # Triggers a requests.delete with url=<user-id>
  • If your resource return other nested resources you can parse them as well:
class Pet(ViewsetRestApiLib):
    base_api_url = ''
    nested_objects = {
        'owner': User,

pet = Pet.retrieve('pet-id')
isinstance(pet, Pet)
isinstance(pet.owner, User)

You can see all possible customizations here (someday I'll improve this doc).

Special thanks:

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
rest_api_lib_creator-0.1.1-py3-none-any.whl (7.0 kB) Copy SHA256 hash SHA256 Wheel py3
rest-api-lib-creator-0.1.1.tar.gz (18.1 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