Skip to content

mrevutskyi/flask-restless-ng

 
 

Repository files navigation

Flask-Restless-NG

PyPI version Build Status Coverage Status Documentation Status

About

This is a Flask extension that creates URL endpoints that satisfy the requirements of the JSON API specification. It is compatible with models that have been defined using either SQLAlchemy or Flask-SQLAlchemy.

This is a fork of Flask-Restless module originally written by Jeffrey Finkelstein.

Version 1.0.* of Flask-Restless-NG is fully API compatible with Flask-Restless version 1.0.0b1 with the following improvements:

  • Supports Flask 2.2+ and SQLAlchemy 1.4.x-2.0.x
  • 2-5x faster serialization of JSON responses.
  • Miscellaneous bugs fixed

Version 2.0.* adds a few backward incompatible changes with more performance improvements

Introduction

This is Flask-Restless, a Flask extension that creates URL endpoints that satisfy the requirements of the JSON API specification. It is compatible with models that have been defined using either SQLAlchemy or Flask-SQLAlchemy.

This document contains some brief instructions concerning installation of requirements, installation of this extension, configuration and usage of this extension, and building of documentation.

For more information, see the

Installing

This application can be used with any Python version 3.6+

pip install Flask-Restless-NG

Example

import flask
import flask_restless
import flask_sqlalchemy

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


class Person(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Unicode)
    birth_date = db.Column(db.Date)


class Article(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.Unicode)
    published_at = db.Column(db.DateTime)
    author_id = db.Column(db.Integer, db.ForeignKey('person.id'))
    author = db.relationship(Person, backref=db.backref('articles'))


# Create the database tables.
db.create_all()

# Create the Flask-Restless API manager.
manager = flask_restless.APIManager(app, session=db.session)

# Create API endpoints, which will be available at /api/<table_name> by
# default. Allowed HTTP methods can be specified as well.
manager.create_api(Person, methods=['GET', 'POST', 'DELETE'])
manager.create_api(Article, methods=['GET'])

# start the flask loop
app.run()

More information on how to use this extension is available in the documentation.

Feedback

Please fill out the feedback form, this would help me determine if this package is still valuable

Contact

Maksym Revutskyi maksym.revutskyi@gmail.com

About

A Flask extension for creating simple ReSTful JSON APIs from SQLAlchemy models.

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE.md
AGPL-3.0
LICENSE.AGPL
Unknown
LICENSE.BSD

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.9%
  • Makefile 0.1%