Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/app-generator/django-dynamic-api
Django Dynamic API - Open-Source Library | AppSeed
https://github.com/app-generator/django-dynamic-api
api-development api-devtool api-rest api-rest-server django-api django-api-generator django-api-sample django-generator django-rest-framework drf-generator drf-sample
Last synced: about 2 months ago
JSON representation
Django Dynamic API - Open-Source Library | AppSeed
- Host: GitHub
- URL: https://github.com/app-generator/django-dynamic-api
- Owner: app-generator
- License: mit
- Created: 2022-10-24T05:56:09.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-17T04:35:09.000Z (2 months ago)
- Last Synced: 2024-10-19T06:50:32.887Z (2 months ago)
- Topics: api-development, api-devtool, api-rest, api-rest-server, django-api, django-api-generator, django-api-sample, django-generator, django-rest-framework, drf-generator, drf-sample
- Language: Python
- Homepage: https://app-generator.dev/docs/developer-tools/dynamic-api.html
- Size: 29.3 KB
- Stars: 16
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# [Django Dynamic API](https://app-generator.dev/docs/developer-tools/dynamic-api.html)
Simple tool that **Generates Secure APIs** on top of `DRF` with minimum effort - actively supported by **[App-Generator](https://app-generator.dev/)**.
- [Dynamic API Features](https://www.youtube.com/watch?v=nPQMUafTrNY) - video presentation
---
> For a **complete set of features** and long-term support, check out **[Dynamic Django](https://app-generator.dev/docs/developer-tools/dynamic-django/index.html)**, a powerful starter that incorporates:
- [Dynamic DataTables](https://app-generator.dev/docs/developer-tools/dynamic-django/datatables.html): using a single line of configuration, the data saved in any table is automatically managed
- [Dynamic API](https://app-generator.dev/docs/developer-tools/dynamic-django/api.html): any model can become a secure API Endpoint using DRF
- [Dynamic Charts](https://app-generator.dev/docs/developer-tools/dynamic-django/charts.html): extract relevant charts without coding all major types are supported
- [CSV Loader](https://app-generator.dev/docs/developer-tools/dynamic-django/csv-loader.html): translate CSV files into Django Models and (optional) load the information
- Powerful [CLI Tools](https://app-generator.dev/docs/developer-tools/dynamic-django/cli.html) for the GIT interface, configuration editing, updating the configuration and database (create models, migrate DB)
## `Dynamic API Features`
- `API engine` provided by `DRF`
- `Minimal Configuration` (single line in config for each model)
- `Handles any model` defined across the project
![Django Dynamic API - DRF Interface (open-source tool).](https://user-images.githubusercontent.com/51070104/197181145-f7458df7-23c3-4c14-bcb1-8e168882a104.jpg)
## How to use it
> **Step #1** - `Install the package`
```bash
$ pip install django-dynamic-api
// OR
$ pip install git+https://github.com/app-generator/django-dynamic-api.git
```
> **Step #2** - `Update Configuration`, include the new APPs
```python
INSTALLED_APPS = [
'django_dyn_api', # Django Dynamic API # <-- NEW
'rest_framework', # Include DRF # <-- NEW
'rest_framework.authtoken', # Include DRF Auth # <-- NEW
]
```
> **Step #3** - `Register the model` in `core/settings.py` (DYNAMIC_API section)
This sample code assumes that `app1` exists and model `Book` is defined and migrated.
```python
DYNAMIC_API = {
# pattern:
# API_SLUG -> Import_PATH
'books' : "app1.models.Book",
}REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
}```
> **Step #4** - `Migrate DB` and create the tables used by `DRF`
```bash
$ python manage.py makemigrations
$ python manage.py migrate
```
> **Step #5** - `Update routing`, include APIs
```python
from django.contrib import admin
from django.urls import path, include # <-- UPD: 'include` directive
from rest_framework.authtoken.views import obtain_auth_token # <-- NEWurlpatterns = [
path("admin/", admin.site.urls),
path('', include('django_dyn_api.urls')), # <-- NEW
path('login/jwt/', view=obtain_auth_token), # <-- NEW
]
```
> **Step #6** - `Use API`
If the managed model is `Books`, the API interface is `/api/books/` and all CRUD methods are available.
> Note: for mutating requests, the `JWT Token` is provided by `http://localhost:8000/login/jwt/` route (the user should exist).
![Django API Generator - POSTMAN Interface (open-source tool).](https://user-images.githubusercontent.com/51070104/197181265-eb648e27-e5cf-4f3c-b330-d000aba53c6a.jpg)
### Links & resources
- [DRF](https://www.django-rest-framework.org/) - HOMEpage
- More [Developer Tools](https://appseed.us/developer-tools/) provided by `AppSeed`
- Ask for [Support](https://appseed.us/support/) via `Email` & `Discord`
---
[Django Dynamic API](https://app-generator.dev/docs/developer-tools/dynamic-api.html) - Open-source library provided by **[App-Generator](https://app-generator.dev/)**