Skip to main content

Flask extension to build REST APIs based on SQLAlchemy models

Project description

Flask-RESTAlchemy

build codecov black black

A Flask extension to build REST APIs. It dismiss the need of building Schema classes, since usually all the information needed to serialize an SQLAlchemy instance is in the model itself.

By adding a model to the API, all its properties will be exposed:

class User(Base):

    __tablename__ = "User"

    id = Column(Integer, primary_key=True)
    firstname = Column(String)
    lastname = Column(String)
    email = Column(String)
    password = Column(String)


api = Api(flask_app)
api.add_model(User, "/user")

To change the way properties are serialized, declare only the one that needs a non-default behaviour:

from serialchemy import ModelSerializer, Field


class UserSerializer(ModelSerializer):

    password = Field(load_only=True)


api = Api(flask_app)
api.add_model(User, "/user", serializer_class=UserSerializer)

Release

A reminder for the maintainers on how to make a new release.

Note that the VERSION should folow the semantic versioning as X.Y.Z Ex.: v1.0.5

  1. Create a release-VERSION branch from upstream/master.
  2. Update CHANGELOG.rst.
  3. Push a branch with the changes.
  4. Once all builds pass, push a VERSION tag to upstream.
  5. Merge the PR.

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-restalchemy-0.15.0.dev0.tar.gz (27.0 kB view hashes)

Uploaded Source

Built Distribution

flask_restalchemy-0.15.0.dev0-py3-none-any.whl (29.7 kB view hashes)

Uploaded Python 3

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