Awesome Open Source
Awesome Open Source

============ Flask-Potion

.. image:: :target:

.. image:: :target:

.. image:: :target:

.. image:: :target:

.. image:: :alt: Join the chat at :target:


.. image:: :alt: Flask-Potion :align: center :height: 150


Flask-Potion is a powerful Flask extension for building RESTful JSON APIs. Potion features include validation, model resources and routes, relations, object permissions, filtering, sorting, pagination, signals, and automatic API schema generation.

Potion ships with backends for SQLAlchemy, peewee and MongoEngine models. It is possible to add backends for other data stores, or even to use a subset of Potion without any data store at all.

API client libraries for Python <>_ and JavaScript/TypeScript <>_ (generic Node as well as AngularJS and Angular) are available.

User's Guide ^^^^^^^^^^^^

The user's guide and documentation is published here: <>_

Versioning ^^^^^^^^^^

Potion will use semantic versioning from v1.0.0. Until then, the minor version is used for changes known to be breaking.


  • Powerful API framework both for data-store-linked and plain resources

  • JSON-based and fully self-documenting with JSON Hyper-Schema

  • Backend integrations:

    • Flask-SQLAlchemy
    • Peewee (contributed by Michael Lavers <>_)
    • Flask-MongoEngine
  • Filtering, sorting, pagination, validation, built right in

  • Smart system for handling relations between resources

  • Natural keys for extra simple relation querying

  • Easy-to-use, yet highly flexible, optional permissions system

  • Signals for pre- and post-processing of requests

  • Very customizable — everything is just a resource, route, or schema

  • Access APIs more easily with client libraries for Python <>_ and JavaScript/TypeScript <>_

Example (SQLAlchemy)

.. code-block:: python

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_potion import Api, ModelResource, fields
from flask_potion.routes import ItemRoute

app = Flask(__name__)
db = SQLAlchemy(app)
api = Api(app)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(), nullable=False)


class UserResource(ModelResource):
    class Meta:
        model = User

    def greeting(self, user) -> fields.String():
        return "Hello, {}!".format(


if __name__ == '__main__':


Potion is written and maintained by Lars Schöning <>_.

Peewee <>_ backend support has been contributed by Michael Lavers <>_.

MongoEngine <>_ backend support has been contributed by João Cardoso <>_.

See here for the full list of contributors <>_.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (50,867
flask (496
sqlalchemy (95
flask-extensions (17

Find Open Source By Browsing 7,000 Topics Across 59 Categories