Skip to main content

SAFRS : SqlAlchemy Flask-Restful Swagger

Project description

Latest Version Supported Python versions License: GPL v3 Python application Codacy Badge Downloads

SAFRS

Expose SQLAlchemy models as JSON:API resources and generate API documentation with minimal boilerplate.

SAFRS is built around SQLAlchemy models and JSON:API-style resource handling. The repository includes FastAPI and Flask adapters.

SAFRS demo

Start here

Functionality

  • JSON:API collection and instance endpoints for SQLAlchemy models
  • relationship endpoints and include support
  • filtering, sorting, pagination, sparse fieldsets, and bulk request support
  • custom RPC methods with @jsonapi_rpc
  • generated Swagger / OpenAPI documentation
  • serialization hooks, computed attributes, and model-level customization
  • stateless service-style endpoints through JABase

Install

SAFRS currently requires Python >=3.10.

Install from PyPI:

pip install safrs

Editable install from a clone:

git clone https://github.com/thomaxxl/safrs
cd safrs
python -m venv venv
source venv/bin/activate
pip install -e .

For the broader example set, including auth and admin examples:

pip install -r examples/requirements.txt

More setup details: Installation wiki page

Quick start from this repository

SAFRS models inherit both SAFRSBase and the SQLAlchemy model base. You then expose them with:

  • SafrsApi(...).expose_object(Model) for Flask
  • SafrsFastAPI(...).expose_object(Model) for the FastAPI adapter

Run the smallest Flask example:

python examples/mini_app.py

Run the smallest FastAPI example:

python examples/mini_fastapi_app.py

Quickstarts and walkthroughs:

Example files worth opening first

The full examples index is in the wiki: Examples

Documentation map

Getting started:

Core JSON:API behavior:

Customization and extension:

Advanced topics:

Notes

  • Flask is still the main documented SAFRS path.
  • The FastAPI adapter exists in the repository and is documented, but it should still be treated as experimental.
  • The older expose-existing-database workflow is no longer the main recommended entry point and is kept as legacy documentation.

SAFRS originally stood for SqlAlchemy Flask-Restful Swagger. The project has since grown beyond the original Flask-only framing, but the historical name remains.

Project details


Release history Release notifications | RSS feed

This version

3.2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

safrs-3.2.0.tar.gz (139.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safrs-3.2.0-py3-none-any.whl (137.6 kB view details)

Uploaded Python 3

File details

Details for the file safrs-3.2.0.tar.gz.

File metadata

  • Download URL: safrs-3.2.0.tar.gz
  • Upload date:
  • Size: 139.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for safrs-3.2.0.tar.gz
Algorithm Hash digest
SHA256 19cdce80fd0abc17320b313ba61721c0e3591b56aa16ff424efbb1f3bc43f73c
MD5 99a277691279768bfbcb9c30b7ce7ca8
BLAKE2b-256 240030427071b9041fdac187f10ede8b189d5b296feb17fe3a406c56fea8bd22

See more details on using hashes here.

File details

Details for the file safrs-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: safrs-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 137.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for safrs-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab0b9e52534b40c6b4617d05a7a362695a536843c4b9f6597dd6547bbd25736e
MD5 2ed95cdc47669d7701d9540815cca2e2
BLAKE2b-256 c311cd15c93da768cb45434e85f410e672543e8e18821e7b776269bebbc35786

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page