Skip to content
quickly generate rest api by plugging in db connection string
Python TSQL
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

api generator

  • this tool automatically generates python code for a rest api and corresponding api doc using swagger ui, all you've to do is provide connection string to the database and verify configuration settings

  • it leverages fastapi, which uses and ASGI server uvicorn

  • currently only postgres is supported


required : python3.6+, pip3

  • git clone
  • cd api_generator
  • install pre-requisite for psycopg2 and requirements:
sudo apt-get install libpq-dev python3-dev
pip3 install -r requirements.txt
  • update connection string and schema for which api is to be generated in the settings.conf

  • generate configuration file for the api generator, the api and the model will be generated based on the settings in this conf file in next steps. this will create a file named api_gen.conf

  • go through the settings in the api_gen.conf, top of the file contains the description of each setting

  • run script to generate api code and model inside the src folder

  • cd src (you can also move and rename the src to any location)

  • the src folder has all the api code, first install library requirements:

pip3 install -r requirements.txt
  • run the api app:
uvicorn app:app --reload


  • support for custom select queriers(complex or simple) will be added

  • support for tables with composite keys as primary key will be added

  • currently table names or column names with spaces in your db are not supported by this tool, it will potentially break the code

  • all fields are set to be required by default, you can modify the class files inside the model folder to set default value of fields to None, this will make those fields optional

  • redirects to /docs by default, /docs are the swagger ui docs using which you can test all the api calls and /redoc is an alternate documentation

sample project

if you want to look at an already generated api project, a sample project is included,

follow the readme inside it if you want to try that to see how a generated api will look like

You can’t perform that action at this time.