The base to start an openapi project featuring: SQLModel, Typer, FastAPI, JWT Token Auth, Interactive Shell, Management Commands.


FastAPI Project Template

The base to start an openapi project featuring: SQLModel, Typer, FastAPI, JWT Token Auth, Interactive Shell, Management Commands.

See also


DO NOT FORK this is meant to be used from Use this template feature.

  1. Click on Use this template
  2. Give a name to your project
    (e.g. my_awesome_project recommendation is to use all lowercase and underscores separation for repo names.)
  3. Wait until the first run of CI finishes
    (Github Actions will process the template and commit to your new repo)
  4. If you want codecov Reports and Automatic Release to PyPI
    On the new repository settings->secrets add your PIPY_API_TOKEN and CODECOV_TOKEN (get the tokens on respective websites)
  5. Read the file
  6. Then clone your new project and happy coding!

NOTE: WAIT until first CI run on github actions before cloning your new project.

What is included on this template?

  • 🖼️ The base to start an openapi project featuring: SQLModel, Typer, FastAPI, VueJS.
  • 📦 A basic file to provide installation, packaging and distribution for your project.
    Template uses setuptools because it's the de-facto standard for Python packages, you can run make switch-to-poetry later if you want.
  • 🤖 A Makefile with the most useful commands to install, test, lint, format and release your project.
  • 📃 Documentation structure using mkdocs
  • 💬 Auto generation of change log using gitchangelog to keep a file automatically based on your commit history on every release.
  • 🐋 A simple Containerfile to build a container image for your project.
    Containerfile is a more open standard for building container images than Dockerfile, you can use buildah or docker with this file.
  • 🧪 Testing structure using pytest
  • ✅ Code linting using flake8
  • 📊 Code coverage reports using codecov
  • 🛳️ Automatic release to PyPI using twine and github actions.
  • 🎯 Entry points to execute your program using python -m or $ project_name with basic CLI argument parsing.
  • 🔄 Continuous integration using Github Actions with jobs to lint, test and release your project on Linux, Mac and Windows environments.

Curious about architectural decisions on this template? read
If you want to contribute to this template please open an issue or fork and send a PULL REQUEST.

❤️ Sponsor this project


codecov CI



from source

git clone project_name
cd project_name
make install

from pypi

pip install project_name


$ project_name run --port 8080


python -m project_name run --port 8080


$ uvicorn project_name:app


❯ project_name --help
Usage: project_name [OPTIONS] COMMAND [ARGS]...

  --install-completion [bash|zsh|fish|powershell|pwsh]
                                  Install completion for the specified shell.
  --show-completion [bash|zsh|fish|powershell|pwsh]
                                  Show completion for the specified shell, to
                                  copy it or customize the installation.
  --help                          Show this message and exit.

  create-user  Create user
  run          Run the API server.
  shell        Opens an interactive shell with objects auto imported

Creating a user

❯ project_name create-user --help
Usage: project_name create-user [OPTIONS] USERNAME PASSWORD

  Create user

  USERNAME  [required]
  PASSWORD  [required]

  --superuser / --no-superuser  [default: no-superuser]

IMPORTANT To create an admin user on the first run:

project_name create-user admin admin --superuser

The Shell

You can enter an interactive shell with all the objects imported.

❯ project_name shell       
Auto imports: ['app', 'settings', 'User', 'engine', 'cli', 'create_user', 'select', 'session', 'Content']

In [1]: session.query(Content).all()
Out[1]: [Content(text='string', title='string', created_time='2021-09-14T19:25:00.050441', user_id=1, slug='string', id=1, published=False, tags='string')]

In [2]: user = session.get(User, 1)

In [3]: user.contents
Out[3]: [Content(text='string', title='string', created_time='2021-09-14T19:25:00.050441', user_id=1, slug='string', id=1, published=False, tags='string')]


Run with project_name run and access

For some api calls you must authenticate using the user created with project_name create-user.


❯ make test
Black All done! ✨ 🍰 ✨
13 files would be left unchanged.
Isort All done! ✨ 🍰 ✨
6 files would be left unchanged.
Success: no issues found in 13 source files
================================ test session starts ===========================
platform linux -- Python 3.9.6, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- 
cachedir: .pytest_cache
rootdir: /fastapi-project-template
plugins: cov-2.12.1
collected 10 items                                                                                                                               

tests/ PASSED                           [ 10%]
tests/ PASSED                                      [ 20%]
tests/ PASSED                                       [ 30%]
tests/[run-args0---port] PASSED                [ 40%]
tests/[create-user-args1-create-user] PASSED   [ 50%]
tests/[create-user-args0-created admin2 user] PASSED[ 60%]
tests/ PASSED                     [ 70%]
tests/ PASSED                       [ 80%]
tests/ PASSED                             [ 90%]
tests/ PASSED                           [100%]

----------- coverage: platform linux, python 3.9.6-final-0 -----------
Name                              Stmts   Miss  Cover
project_name/              4      0   100%
project_name/                  16      1    94%
project_name/                  21      0   100%
project_name/                5      0   100%
project_name/                   10      0   100%
project_name/models/       0      0   100%
project_name/models/       47      1    98%
project_name/routes/      11      0   100%
project_name/routes/       52     25    52%
project_name/routes/      15      1    93%
project_name/routes/          52     26    50%
project_name/            103     12    88%
TOTAL                               336     66    80%

========================== 10 passed in 2.34s ==================================

Linting and Formatting

make lint  # checks for linting errors
make fmt   # formats the code


This project uses Dynaconf to manage configuration.

from project_name.config import settings

Acessing variables

settings.get("SECRET_KEY", default="sdnfjbnfsdf")

Defining variables

On files


dynaconf_merge = true

echo = true

dynaconf_merge is a boolean that tells if the settings should be merged with the default settings defined in project_name/default.toml.

As environment variables

export PROJECT_NAME_KEY=value
export PROJECT_NAME_KEY="@int 42"
export PROJECT_NAME_KEY="@jinja {{ this.db.uri }}"
export PROJECT_NAME_DB__uri="@jinja {{ this.db.uri | replace('db', 'data') }}"


There is a file .secrets.toml where your sensitive variables are stored, that file must be ignored by git. (add that to .gitignore)

Or store your secrets in environment variables or a vault service, Dynaconf can read those variables.

Switching environments

PROJECT_NAME_ENV=production project_name run



Read the file.

Bruno Rocha
Programmer at @RedHatOfficial. #Python #Rust . Working on: @ansible @python #dynaconf @codeshow
Bruno Rocha
Publish Xarray Datasets via a REST API.

Xpublish Publish Xarray Datasets via a REST API. Serverside: Publish a Xarray Dataset through a rest API"", port=9000) Clie

xarray-contrib 106 Jan 06, 2023
Backend logic implementation for realworld with awesome FastAPI

Backend logic implementation for realworld with awesome FastAPI

Nik 2.2k Jan 08, 2023
Lung Segmentation with fastapi

Lung Segmentation with fastapi This app uses FastAPI as backend. Usage for First install required libraries by running: pip install -r requirem

Pejman Samadi 0 Sep 20, 2022
Minimal example utilizing fastapi and celery with RabbitMQ for task queue, Redis for celery backend and flower for monitoring the celery tasks.

FastAPI with Celery Minimal example utilizing FastAPI and Celery with RabbitMQ for task queue, Redis for Celery backend and flower for monitoring the

Grega Vrbančič 371 Jan 01, 2023
REST API with FastAPI and SQLite3.

REST API with FastAPI and SQLite3

Luis Quiñones Requelme 2 Mar 14, 2022
Backend Skeleton using FastAPI and Sqlalchemy ORM

Backend API Skeleton Based on @tiangolo's full stack postgres template, with some things added, some things removed, and some things changed. This is

David Montague 18 Oct 31, 2022
Auth for use with FastAPI

FastAPI Auth Pluggable auth for use with FastAPI Supports OAuth2 Password Flow Uses JWT access and refresh tokens 100% mypy and test coverage Supports

David Montague 95 Jan 02, 2023
First API using FastApi

First API using FastApi Made this Simple Api to store and Retrive Student Data of My College Ncc-Bim To View All the endpoits Visit /docs To Run Local

Sameer Joshi 2 Jun 21, 2022
API & Webapp to answer questions about COVID-19. Using NLP (Question Answering) and trusted data sources.

This open source project serves two purposes. Collection and evaluation of a Question Answering dataset to improve existing QA/search methods - COVID-

deepset 329 Nov 10, 2022
Code for my JWT auth for FastAPI tutorial

FastAPI tutorial Code for my video tutorial FastAPI tutorial What is FastAPI? FastAPI is a high-performant REST API framework for Python. It's built o

José Haro Peralta 8 Dec 16, 2022
Fastapi practice project

todo-list-fastapi practice project How to run Install dependencies npm, yarn: standard-version, husky make: script for lint, test pipenv: virtualenv +

Deo Kim 10 Nov 30, 2022
A simple api written in python/fastapi that serves movies from a cassandra table.

A simple api written in python/fastapi that serves movies from a cassandra table. 1)clone the repo 2)rename to global_config.

Sreeraj 1 Aug 26, 2021
FastAPI Admin Dashboard based on FastAPI and Tortoise ORM.

FastAPI ADMIN 中文文档 Introduction FastAPI-Admin is a admin dashboard based on fastapi and tortoise-orm. FastAPI-Admin provide crud feature out-of-the-bo

long2ice 1.6k Dec 31, 2022
A rate limiter for Starlette and FastAPI

SlowApi A rate limiting library for Starlette and FastAPI adapted from flask-limiter. Note: this is alpha quality code still, the API may change, and

Laurent Savaete 565 Jan 02, 2023
A Prometheus Python client library for asyncio-based applications

aioprometheus aioprometheus is a Prometheus Python client library for asyncio-based applications. It provides metrics collection and serving capabilit

132 Dec 28, 2022
Money Transaction is a system based on the recent famous FastAPI.

moneyTransfer Overview Money Transaction is a system based on the recent famous FastAPI. techniques selection System's technique selection is as follo

2 Apr 28, 2021
Online Repo Browser

MSYS2 Web Interface A simple web interface for browsing the MSYS2 repos. Rebuild CSS/JS (optional): cd frontend npm install npm run build Run for Dev

MSYS2 64 Dec 30, 2022
A Python pickling decompiler and static analyzer

Fickling Fickling is a decompiler, static analyzer, and bytecode rewriter for Python pickle object serializations. Pickled Python objects are in fact

Trail of Bits 162 Dec 13, 2022
Reusable utilities for FastAPI

Reusable utilities for FastAPI Documentation: Source Code: FastAPI i

David Montague 1.3k Jan 04, 2023

MLServer An open source inference server to serve your machine learning models. ⚠️ This is a Work in Progress. Overview MLServer aims to provide an ea

Seldon 341 Jan 03, 2023