{"id":13501792,"url":"https://github.com/miLibris/flask-rest-jsonapi","last_synced_at":"2025-03-29T09:31:27.987Z","repository":{"id":46057813,"uuid":"71563227","full_name":"miLibris/flask-rest-jsonapi","owner":"miLibris","description":"Flask extension to build REST APIs around JSONAPI 1.0 specification.","archived":false,"fork":false,"pushed_at":"2024-07-04T10:43:59.000Z","size":672,"stargazers_count":598,"open_issues_count":58,"forks_count":154,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-03-20T14:13:29.571Z","etag":null,"topics":["flask","jsonapi","marshmallow","sqlalchemy"],"latest_commit_sha":null,"homepage":"http://flask-rest-jsonapi.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miLibris.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-21T12:29:30.000Z","updated_at":"2025-01-12T15:56:10.000Z","dependencies_parsed_at":"2024-06-18T19:44:33.588Z","dependency_job_id":"3b38f4fe-ed67-48b2-8dd2-01abf6a558f7","html_url":"https://github.com/miLibris/flask-rest-jsonapi","commit_stats":{"total_commits":555,"total_committers":38,"mean_commits":"14.605263157894736","dds":0.4288288288288288,"last_synced_commit":"a4ff3f4d5be78071f015efe003e976d31d4eba10"},"previous_names":[],"tags_count":81,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miLibris%2Fflask-rest-jsonapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miLibris%2Fflask-rest-jsonapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miLibris%2Fflask-rest-jsonapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miLibris%2Fflask-rest-jsonapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miLibris","download_url":"https://codeload.github.com/miLibris/flask-rest-jsonapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245868318,"owners_count":20685607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","jsonapi","marshmallow","sqlalchemy"],"created_at":"2024-07-31T22:01:50.500Z","updated_at":"2025-03-29T09:31:27.965Z","avatar_url":"https://github.com/miLibris.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":".. image:: https://badge.fury.io/py/Flask-REST-JSONAPI.svg\n    :target: https://badge.fury.io/py/Flask-REST-JSONAPI\n.. image:: https://travis-ci.org/miLibris/flask-rest-jsonapi.svg\n    :target: https://travis-ci.org/miLibris/flask-rest-jsonapi\n.. image:: https://coveralls.io/repos/github/miLibris/flask-rest-jsonapi/badge.svg\n    :target: https://coveralls.io/github/miLibris/flask-rest-jsonapi\n.. image:: https://readthedocs.org/projects/flask-rest-jsonapi/badge/?version=latest\n    :target: http://flask-rest-jsonapi.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\nFlask-REST-JSONAPI\n##################\n\nFlask-REST-JSONAPI is a flask extension for building REST APIs. It combines the power of `Flask-Restless \u003chttps://flask-restless.readthedocs.io/\u003e`_ and the flexibility of `Flask-RESTful \u003chttps://flask-restful.readthedocs.io/\u003e`_ around a strong specification `JSONAPI 1.0 \u003chttp://jsonapi.org/\u003e`_. This framework is designed to quickly build REST APIs and fit the complexity of real life projects with legacy data and multiple data storages.\n\nInstall\n=======\n\n    pip install Flask-REST-JSONAPI\n\nA minimal API\n=============\n\n.. code-block:: python\n\n    # -*- coding: utf-8 -*-\n\n    from flask import Flask\n    from flask_rest_jsonapi import Api, ResourceDetail, ResourceList\n    from flask_sqlalchemy import SQLAlchemy\n    from marshmallow_jsonapi.flask import Schema\n    from marshmallow_jsonapi import fields\n\n    # Create the Flask application and the Flask-SQLAlchemy object.\n    app = Flask(__name__)\n    app.config['DEBUG'] = True\n    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'\n    db = SQLAlchemy(app)\n\n    # Create model\n    class Person(db.Model):\n        id = db.Column(db.Integer, primary_key=True)\n        name = db.Column(db.String)\n\n    # Create the database.\n    db.create_all()\n\n    # Create schema\n    class PersonSchema(Schema):\n        class Meta:\n            type_ = 'person'\n            self_view = 'person_detail'\n            self_view_kwargs = {'id': '\u003cid\u003e'}\n            self_view_many = 'person_list'\n\n        id = fields.Integer(as_string=True, dump_only=True)\n        name = fields.Str()\n\n    # Create resource managers\n    class PersonList(ResourceList):\n        schema = PersonSchema\n        data_layer = {'session': db.session,\n                      'model': Person}\n\n    class PersonDetail(ResourceDetail):\n        schema = PersonSchema\n        data_layer = {'session': db.session,\n                      'model': Person}\n\n    # Create the API object\n    api = Api(app)\n    api.route(PersonList, 'person_list', '/persons')\n    api.route(PersonDetail, 'person_detail', '/persons/\u003cint:id\u003e')\n\n    # Start the flask loop\n    if __name__ == '__main__':\n        app.run()\n\nThis example provides the following API structure:\n\n========================  ======  =============  ===========================\nURL                       method  endpoint       Usage\n========================  ======  =============  ===========================\n/persons                  GET     person_list    Get a collection of persons\n/persons                  POST    person_list    Create a person\n/persons/\u003cint:person_id\u003e  GET     person_detail  Get person details\n/persons/\u003cint:person_id\u003e  PATCH   person_detail  Update a person\n/persons/\u003cint:person_id\u003e  DELETE  person_detail  Delete a person\n========================  ======  =============  ===========================\n\nFlask-REST-JSONAPI vs `Flask-RESTful \u003chttp://flask-restful-cn.readthedocs.io/en/0.3.5/a\u003e`_\n==========================================================================================\n\n* 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.\n* Flask-REST-JSONAPI is as flexible as Flask-RESTful. You can rewrite every default method implementation to make custom work like distributing object creation.\n\nFlask-REST-JSONAPI vs `Flask-Restless \u003chttps://flask-restless.readthedocs.io/en/stable/\u003e`_\n==========================================================================================\n\n* 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 \u003chttps://marshmallow.readthedocs.io/en/latest/\u003e`_. So you can create complex resource over your data.\n* In contrast to Flask-Restless, Flask-REST-JSONAPI can use any ORM or data storage through the data layer concept, not only `SQLAlchemy \u003chttp://www.sqlalchemy.org/\u003e`_. 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.\n* 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.\n* 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.\n* 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.\n* 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.\n\nDocumentation\n=============\n\nDocumentation available here: http://flask-rest-jsonapi.readthedocs.io/en/latest/\n\nThanks\n======\n\nFlask, 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FmiLibris%2Fflask-rest-jsonapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FmiLibris%2Fflask-rest-jsonapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FmiLibris%2Fflask-rest-jsonapi/lists"}