All Projects → miLibris → Flask Rest Jsonapi

miLibris / Flask Rest Jsonapi

Licence: mit
Flask extension to build REST APIs around JSONAPI 1.0 specification.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Flask Rest Jsonapi

Hobbit Core
A flask project generator.
Stars: ✭ 49 (-91.34%)
Mutual labels:  marshmallow, sqlalchemy, flask
Python Api Development Fundamentals
Develop a full-stack web application with Python and Flask
Stars: ✭ 44 (-92.23%)
Mutual labels:  marshmallow, sqlalchemy, flask
Flask Marshmallow
Flask + marshmallow for beautiful APIs
Stars: ✭ 666 (+17.67%)
Mutual labels:  marshmallow, sqlalchemy, flask
Full Stack
Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
Stars: ✭ 451 (-20.32%)
Mutual labels:  marshmallow, sqlalchemy, flask
Flasgger
Easy OpenAPI specs and Swagger UI for your Flask API
Stars: ✭ 2,825 (+399.12%)
Mutual labels:  marshmallow, flask
Marshmallow Jsonapi
JSON API 1.0 (https://jsonapi.org/) formatting with marshmallow
Stars: ✭ 203 (-64.13%)
Mutual labels:  marshmallow, flask
Potion
Flask-Potion is a RESTful API framework for Flask and SQLAlchemy, Peewee or MongoEngine
Stars: ✭ 484 (-14.49%)
Mutual labels:  sqlalchemy, flask
Flask Smorest
DB agnostic framework to build auto-documented REST APIs with Flask and marshmallow
Stars: ✭ 317 (-43.99%)
Mutual labels:  marshmallow, flask
Safrs
SqlAlchemy Flask-Restful Swagger Json:API OpenAPI
Stars: ✭ 255 (-54.95%)
Mutual labels:  sqlalchemy, flask
Flask Sqlalchemy
Adds SQLAlchemy support to Flask
Stars: ✭ 3,658 (+546.29%)
Mutual labels:  sqlalchemy, flask
Marshmallow Sqlalchemy
SQLAlchemy integration with marshmallow
Stars: ✭ 426 (-24.73%)
Mutual labels:  marshmallow, sqlalchemy
Flask Restplus Server Example
Real-life RESTful server example on Flask-RESTplus
Stars: ✭ 1,240 (+119.08%)
Mutual labels:  marshmallow, flask
Webargs
A friendly library for parsing HTTP request arguments, with built-in support for popular web frameworks, including Flask, Django, Bottle, Tornado, Pyramid, webapp2, Falcon, and aiohttp.
Stars: ✭ 1,145 (+102.3%)
Mutual labels:  marshmallow, flask
flask-rest-api
This program shows how to set up a flaskrestapi with postgre db, blueprint, sqlalchemy, marshmallow, wsgi, unittests
Stars: ✭ 28 (-95.05%)
Mutual labels:  sqlalchemy, marshmallow
Data Driven Web Apps With Flask
Course demo code and other hand-out materials for our data-driven web apps in Flask course
Stars: ✭ 388 (-31.45%)
Mutual labels:  sqlalchemy, flask
Mini Shop Server
基于 Flask 框架开发的微信小程序后端项目,用于构建小程序商城后台 (电商相关;rbac权限管理;附带自动生成Swagger 风格的API 文档;可作「Python 项目毕设」;慕课网系列)---- 相关博客链接:🌟
Stars: ✭ 446 (-21.2%)
Mutual labels:  sqlalchemy, flask
Flask Sqlacodegen
🍶 Automatic model code generator for SQLAlchemy with Flask support
Stars: ✭ 283 (-50%)
Mutual labels:  sqlalchemy, flask
Apispec
A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..
Stars: ✭ 831 (+46.82%)
Mutual labels:  marshmallow, flask
Enferno
A Python framework based on Flask microframework, with batteries included, and best practices in mind.
Stars: ✭ 385 (-31.98%)
Mutual labels:  sqlalchemy, flask
Flask Restplus Boilerplate
A boilerplate for flask restful web service
Stars: ✭ 466 (-17.67%)
Mutual labels:  sqlalchemy, flask

.. image:: https://badge.fury.io/py/Flask-REST-JSONAPI.svg :target: https://badge.fury.io/py/Flask-REST-JSONAPI .. image:: https://travis-ci.org/miLibris/flask-rest-jsonapi.svg :target: https://travis-ci.org/miLibris/flask-rest-jsonapi .. image:: https://coveralls.io/repos/github/miLibris/flask-rest-jsonapi/badge.svg :target: https://coveralls.io/github/miLibris/flask-rest-jsonapi .. image:: https://readthedocs.org/projects/flask-rest-jsonapi/badge/?version=latest :target: http://flask-rest-jsonapi.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

Flask-REST-JSONAPI ##################

Flask-REST-JSONAPI is a flask extension for building REST APIs. It combines the power of Flask-Restless <https://flask-restless.readthedocs.io/>_ and the flexibility of Flask-RESTful <https://flask-restful.readthedocs.io/>_ around a strong specification JSONAPI 1.0 <http://jsonapi.org/>_. This framework is designed to quickly build REST APIs and fit the complexity of real life projects with legacy data and multiple data storages.

Install

pip install Flask-REST-JSONAPI

A minimal API

.. code-block:: python

# -*- coding: utf-8 -*-

from flask import Flask
from flask_rest_jsonapi import Api, ResourceDetail, ResourceList
from flask_sqlalchemy import SQLAlchemy
from marshmallow_jsonapi.flask import Schema
from marshmallow_jsonapi import fields

# Create the Flask application and the Flask-SQLAlchemy object.
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)

# Create model
class Person(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)

# Create the database.
db.create_all()

# Create schema
class PersonSchema(Schema):
    class Meta:
        type_ = 'person'
        self_view = 'person_detail'
        self_view_kwargs = {'id': '<id>'}
        self_view_many = 'person_list'

    id = fields.Integer(as_string=True, dump_only=True)
    name = fields.Str()

# Create resource managers
class PersonList(ResourceList):
    schema = PersonSchema
    data_layer = {'session': db.session,
                  'model': Person}

class PersonDetail(ResourceDetail):
    schema = PersonSchema
    data_layer = {'session': db.session,
                  'model': Person}

# Create the API object
api = Api(app)
api.route(PersonList, 'person_list', '/persons')
api.route(PersonDetail, 'person_detail', '/persons/<int:id>')

# Start the flask loop
if __name__ == '__main__':
    app.run()

This example provides the following API structure:

======================== ====== ============= =========================== URL method endpoint Usage ======================== ====== ============= =========================== /persons GET person_list Get a collection of persons /persons POST person_list Create a person /persons/int:person_id GET person_detail Get person details /persons/int:person_id PATCH person_detail Update a person /persons/int:person_id DELETE person_detail Delete a person ======================== ====== ============= ===========================

Flask-REST-JSONAPI vs Flask-RESTful <http://flask-restful-cn.readthedocs.io/en/0.3.5/a>_

  • In contrast to Flask-RESTful, Flask-REST-JSONAPI provides a default implementation of get, post, patch and delete methods around a strong specification JSONAPI 1.0. Thanks to this you can build REST API very quickly.
  • Flask-REST-JSONAPI is as flexible as Flask-RESTful. You can rewrite every default method implementation to make custom work like distributing object creation.

Flask-REST-JSONAPI vs Flask-Restless <https://flask-restless.readthedocs.io/en/stable/>_

  • Flask-REST-JSONAPI is a real implementation of JSONAPI 1.0 specification. So in contrast to Flask-Restless, Flask-REST-JSONAPI forces you to create a real logical abstration over your data models with Marshmallow <https://marshmallow.readthedocs.io/en/latest/>_. So you can create complex resource over your data.
  • In contrast to Flask-Restless, Flask-REST-JSONAPI can use any ORM or data storage through the data layer concept, not only SQLAlchemy <http://www.sqlalchemy.org/>_. A data layer is a CRUD interface between your resource and one or more data storage so you can fetch data from any data storage of your choice or create resource that use multiple data storages.
  • Like I said previously, Flask-REST-JSONAPI is a real implementation of JSONAPI 1.0 specification. So in contrast to Flask-Restless you can manage relationships via REST. You can create dedicated URL to create a CRUD API to manage relationships.
  • Plus Flask-REST-JSONAPI helps you to design your application with strong separation between resource definition (schemas), resource management (resource class) and route definition to get a great organization of your source code.
  • In contrast to Flask-Restless, Flask-REST-JSONAPI is highly customizable. For example you can entirely customize your URLs, define multiple URLs for the same resource manager, control serialization parameters of each method and lots of very useful parameters.
  • Finally in contrast to Flask-Restless, Flask-REST-JSONAPI provides a great error handling system according to JSONAPI 1.0. Plus the exception handling system really helps the API developer to quickly find missing resources requirements.

Documentation

Documentation available here: http://flask-rest-jsonapi.readthedocs.io/en/latest/

Thanks

Flask, marshmallow, marshmallow_jsonapi, sqlalchemy, Flask-RESTful and Flask-Restless are awesome projects. These libraries gave me inspiration to create Flask-REST-JSONAPI, so huge thanks to authors and contributors.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].