https://github.com/app-generator/flask-dynamic-api
Flask Dynamic API - Developer Tool | AppSeed
https://github.com/app-generator/flask-dynamic-api
api appseed dynamic-programming flask open-source
Last synced: 5 months ago
JSON representation
Flask Dynamic API - Developer Tool | AppSeed
- Host: GitHub
- URL: https://github.com/app-generator/flask-dynamic-api
- Owner: app-generator
- License: other
- Created: 2022-07-19T13:26:35.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-22T06:08:53.000Z (almost 3 years ago)
- Last Synced: 2025-04-06T18:13:28.603Z (about 1 year ago)
- Topics: api, appseed, dynamic-programming, flask, open-source
- Language: SCSS
- Homepage: https://appseed.us
- Size: 25.2 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Flask Dynamic API via `Flask-RestX`
This tool aims to provide a secure, `production-ready API via Flask-RestX` using the developer's minimum amount of code.
For newcomers, **Flask** is a leading backend framework used to code from simple websites and API's to complex eCommerce solutions.
**Flask-RestX** is a popular library for developing secure API services using Flask.
- 👉 Free [support](https://appseed.us/support/) via Email and [Discord](https://discord.gg/fZC6hup)
- 👉 More [Developer Tools](https://appseed.us/developer-tools/) - provided by AppSeed
## Video Presentation
https://user-images.githubusercontent.com/51070104/194328733-3bdf8c70-f765-4168-983d-2a51e276239b.mp4
## Manual Build
> Clone/Download Sources
```bash
$ git clone https://github.com/app-generator/flask-dynamic-api.git
$ cd flask-dynamic-api
```
> Install Modules
```bash
$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements.txt
```
> Update ENV
```bash
$ export FLASK_APP=run.py
```
> Migrate DB
```bash
$ flask db init # INIT needs to be executed only once
$ flask db migrate # Needs to be executed at each DB Schema Update
$ flask db upgrade # Needs to be executed at each DB Schema Update
```
> Start the project
```bash
$ flask run
```
## How it works
The **Dynamic API** tool aims to enable a secured API service on top of any Flask codebase with a minimum effort. Here are the steps:
- `Define a new model` in the project (an old one can be also used)
- `Execute the database migration` to create/update the associated tables
- `Update the configuration` to enable the Dynamic API over the model
- `Start the app`
- Access the `Dynamic API Service`
For instance, if the new model managed by the Dynamic API is called books, the associate API is exposed at /api/books/
| Status | Item | info |
| --- | --- | --- |
| ✅ | New Models Definition in `apps/models` | - |
| ✅ | The app is saved in `apps/dyn_api` | - |
| ✅ | Models enabled in `apps/config.py` via `DYNAMIC_API` variable | - |
| ✅ | The project exposes automatically a CRUD API over the new model | - |
| ✅ | Path of the service: `/api/books/` | In case the new model is `Books` |
| ✅ | The API is powered via Flask-RestX using best practices | - |
## API Permissions
Before using the API, the user must make a request to the `/login' endpoint and send his username and password.:
```json
POST /login
{
"username": "my_username",
"password": "my_password"
}
```
The server returns a token if approved.
```json
{
"token": "RETURNED_TOKEN"
}
```
To use the features, the user must add a key and value to the headers.
headers of requests:
```json
{
...
"Authorization": "token RETURNED_TOKEN"
...
}
```
**Note:** token will be expired after 24 hours.
---
**Flask Dynamic API** via `Flask-RestX` - Developer tool provided by [AppSeed](https://appseed.us)