{"id":16417410,"url":"https://github.com/StefanVDWeide/flask-api-template","last_synced_at":"2025-10-26T20:30:31.317Z","repository":{"id":37987484,"uuid":"267585593","full_name":"StefanVDWeide/flask-api-template","owner":"StefanVDWeide","description":"A basic template to help kickstart development of a Flask API","archived":false,"fork":false,"pushed_at":"2023-12-10T17:30:32.000Z","size":131,"stargazers_count":70,"open_issues_count":13,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T00:08:27.505Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StefanVDWeide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-28T12:35:30.000Z","updated_at":"2024-12-18T23:24:15.000Z","dependencies_parsed_at":"2024-10-11T07:11:51.848Z","dependency_job_id":"7fd84f6b-e2f6-4647-aba0-ece8b29ba1e3","html_url":"https://github.com/StefanVDWeide/flask-api-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanVDWeide%2Fflask-api-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanVDWeide%2Fflask-api-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanVDWeide%2Fflask-api-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanVDWeide%2Fflask-api-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefanVDWeide","download_url":"https://codeload.github.com/StefanVDWeide/flask-api-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238394323,"owners_count":19464583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T07:11:29.636Z","updated_at":"2025-10-26T20:30:30.966Z","avatar_url":"https://github.com/StefanVDWeide.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Flask REST API Template\nA basic template to help kickstart development of a pure Flask API. This template is completely front-end independent \nand leaves all decisions up to the developer. The template includes basic login functionality based on JWT checks. \nHow this token is stored and sent to the API is entirely up to the developer.\n\n## Features\n* Minimal Flask 2.X App\n* Async/Await Functionallity\n* Unit tests\n* Basic Type Hints\n* Integration With Redis For Background Tasks\n* App Structured Using Blueprints\n* Application Factory Pattern Used\n* Authentication Functionality Using JWT\n* Basic Database Functionality Included (SQLite3)\n* Rate Limiting Functionality Based on Flask-Limiter For All The Routes In The Authentication Blueprint\n* Support for .env and .flaskenv files build in\n\n\n### Application Structure\n\nThe API is divided in six blueprints `auth`, `comments`, `errors`, `posts`, `tasks` and `users`.\n\nThe `auth` blueprint is responsible for all the routes associated with user registration and authentication.\n\nThe `comments` blueprint is responsible for handeling all requests related to comments, suchs as GET, POST and DELETE requests.\n\nThe `errors` blueprint is used to catch all errors and return the correct information.\n\nThe `posts` blueprint, just like the `comments` one, is responsible for handeling all requests related to posts, suchs as GET, POST and DELETE requests.\n\nThe `tasks` blueprint is responsible for requests related to asynchronous background tasks. Such as launching, retrieving the status of a specific task and retrieving all completed tasks.\n\nThe `users` blueprint handles the user related requests. Currently there are two routes which return either information ahout the current user or a different user based on username.\n\n## Installation\n\n##### Template and Dependencies\n\n* Clone this repository:\n\n\t```\n\t$ git clone https://github.com/stefanvdw1/flask-api-template.git\n\t```\n\n### Virtual Environment Setup\n\nIt is preferred to create a virtual environment per project, rather then installing all dependencies of each of your \nprojects system wide. Once you install [virtual env](https://virtualenv.pypa.io/en/stable/installation/), and move to \nyour projects directory through your terminal, you can set up a virtual env with:\n\n```bash\npython3 -m venv .venv\n```\n\n### Dependency installations\n\nTo install the necessary packages:\n\n```bash\nsource venv/bin/activate\npip3 install -r requirements.txt\n```\n\nThis will install the required packages within your venv.\n\n---\n\n### Setting up a SQLite3 Database\n\nDatabase migrations are handled through Flask's Migrate Package, which provides a wrapper around Alembic. Migrations are done for updating and creating necessary tables/entries in your database. Flask provides a neat way of handling these. The files generate by the migrations should be added to source control.\n\nTo setup a SQLite3 database for development (SQLite3 is **not** recommended for production, use something like PostgreSQL or MySQL) you navigate to the folder where `flask_api_template.py` is located and run:\n\n```bash\nexport FLASK_APP=flask_api_template.py\n```\n\nthen you need to initiate your database and the migration folder with the following commands:\n\n```bash\nflask db init\n```\n\n```bash\nflask db migrate \"Your message here\"\n```\n\n```bash\nflask db upgrade\n```\n\n### Migrations\n\nTo make changes to the database structure you can also use the `flask db` commands:\n\n```bash\nexport FLASK_APP=flask_api_template.py\n```\n\n```bash\nflask db migrate -m \"Your message here\"\n```\n\n```bash\nflask db upgrade\n```\n\n---\n\n## Running the Application\n\nOnce you have setup your database, you are ready to run the application.\nAssuming that you have exported your app's path by:\n\n```bash\nexport FLASK_APP=flask_api_template.py\n```\n\nYou can go ahead and run the application with a simple command:\n\n```bash\nflask run\n```\n\n---\n\n## PostgreSQL\nTODO\n\n## Gunicorn\nTODO\n\n## Conclusion\n\nHopefully this template will inspire you to use Flask for your future API projects. If you have any feedback please do let me know or feel free to fork and raise a PR. I'm actively trying to maintain this project so pull request are more than welcome.\n\n### Todo's and Improvements\n\n- [x] Add request limiter\n- [x] Add support for enviroment variables\n- [x] Add async functionality\n- [X] Add marshmallow validation for payloads\n- [X] Add type hints\n- [X] Add redis support and background workers\n- [X] Add GitHub actions to run tests\n- [x] Add GitHub action to check requirements using Dependabot\n- [] Add tests for background tasks\n- [] Add instructions to deploy to a production\n\n\n## Acknowledgements\n[Flask Mega Guide - Miguel Grinberg](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStefanVDWeide%2Fflask-api-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FStefanVDWeide%2Fflask-api-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStefanVDWeide%2Fflask-api-template/lists"}