Skip to main content

Powerful REST API framework for Flask and SQLAlchemy

Project description

https://img.shields.io/travis/biosustain/potion/master.svg?style=flat-square https://img.shields.io/coveralls/biosustain/potion/master.svg?style=flat-square https://img.shields.io/pypi/v/Flask-Potion.svg?style=flat-square https://img.shields.io/pypi/l/Flask-Potion.svg?style=flat-square Join the chat at https://gitter.im/biosustain/potion

Flask-Potion

Description

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:

http://potion.readthedocs.org/

Versioning

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

Features

  • 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)

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)

db.create_all()

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

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

api.add_resource(UserResource)

if __name__ == '__main__':
    app.run()

Authors

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.

Project details


Download files

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

Source Distribution

Flask-Potion-0.16.0.tar.gz (40.8 kB view details)

Uploaded Source

File details

Details for the file Flask-Potion-0.16.0.tar.gz.

File metadata

  • Download URL: Flask-Potion-0.16.0.tar.gz
  • Upload date:
  • Size: 40.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.5

File hashes

Hashes for Flask-Potion-0.16.0.tar.gz
Algorithm Hash digest
SHA256 ed55a6d118d2c11985241d312e3fa6224d49127e13a86de65a762235fdc5da0a
MD5 00f0b1f5c7b9fc41e88177c556bc665c
BLAKE2b-256 9194f51269caef8467f0c68b0e613bf207ddbf9d7acc20f204457d6e053d61d1

See more details on using hashes here.

Supported by

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