# flask-rest-jsonapi-next
[![PyPi Status](https://badge.fury.io/py/flask-rest-jsonapi-next.svg)](https://badge.fury.io/py/flask-rest-jsonapi-next)
[![license](https://img.shields.io/pypi/l/flask-rest-jsonapi-next.svg)](https://opensource.org/licenses/MIT)
[![tests](https://github.com/tadams42/flask-rest-jsonapi-next/actions/workflows/tests.yaml/badge.svg?branch=development)](https://github.com/tadams42/flask-rest-jsonapi-next/actions/workflows/tests.yaml)
[![codecov](https://codecov.io/gh/tadams42/flask-rest-jsonapi-next/branch/development/graph/badge.svg?token=9WIWK7B3XX)](https://codecov.io/gh/tadams42/flask-rest-jsonapi-next)
[![Documentation Status](https://readthedocs.org/projects/flask-rest-jsonapi-next/badge/?version=latest)](http://flask-rest-jsonapi-next.readthedocs.io/en/latest/?badge=latest)
[![python_versions](https://img.shields.io/pypi/pyversions/flask-rest-jsonapi-next.svg)](https://pypi.org/project/flask-rest-jsonapi-next/)
This is a fork of [miLibris/flask-rest-jsonapi](https://github.com/miLibris/flask-rest-jsonapi) project.
`flask-rest-jsonapi-next` is a flask extension for building REST APIs around a strong specification
[JSON:API 1.0](http://jsonapi.org/).
Documentation: [http://flask-rest-jsonapi-next.readthedocs.io/en/latest/](http://flask-rest-jsonapi-next.readthedocs.io/en/latest/)
## Install
```sh
pip install flask-rest-jsonapi-next
```
## A minimal API
```py
from flask import Flask
from flask_rest_jsonapi_next 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 |
## Thanks
Flask, marshmallow, marshmallow_jsonapi, sqlalchemy, Flask-RESTful and Flask-Restless
are awesome projects. These libraries gave me inspiration to create
flask-rest-jsonapi-next, so huge thanks to authors and contributors.
Raw data
{
"_id": null,
"home_page": "",
"name": "flask-rest-jsonapi-next",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Tomislav Adamic <tomislav.adamic@gmail.com>",
"keywords": "web,api,rest,jsonapi,flask,sqlalchemy,marshmallow",
"author": "original miLibris/flask-rest-jsonapi contributors",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/4f/4d/734d2db45fb56ab977b5b81877f68c7b45befa3e3c053481062333fbb22c/flask-rest-jsonapi-next-0.43.1.tar.gz",
"platform": "any",
"description": "# flask-rest-jsonapi-next\n\n[![PyPi Status](https://badge.fury.io/py/flask-rest-jsonapi-next.svg)](https://badge.fury.io/py/flask-rest-jsonapi-next)\n[![license](https://img.shields.io/pypi/l/flask-rest-jsonapi-next.svg)](https://opensource.org/licenses/MIT)\n[![tests](https://github.com/tadams42/flask-rest-jsonapi-next/actions/workflows/tests.yaml/badge.svg?branch=development)](https://github.com/tadams42/flask-rest-jsonapi-next/actions/workflows/tests.yaml)\n[![codecov](https://codecov.io/gh/tadams42/flask-rest-jsonapi-next/branch/development/graph/badge.svg?token=9WIWK7B3XX)](https://codecov.io/gh/tadams42/flask-rest-jsonapi-next)\n[![Documentation Status](https://readthedocs.org/projects/flask-rest-jsonapi-next/badge/?version=latest)](http://flask-rest-jsonapi-next.readthedocs.io/en/latest/?badge=latest)\n[![python_versions](https://img.shields.io/pypi/pyversions/flask-rest-jsonapi-next.svg)](https://pypi.org/project/flask-rest-jsonapi-next/)\n\nThis is a fork of [miLibris/flask-rest-jsonapi](https://github.com/miLibris/flask-rest-jsonapi) project.\n\n`flask-rest-jsonapi-next` is a flask extension for building REST APIs around a strong specification\n[JSON:API 1.0](http://jsonapi.org/).\n\nDocumentation: [http://flask-rest-jsonapi-next.readthedocs.io/en/latest/](http://flask-rest-jsonapi-next.readthedocs.io/en/latest/)\n\n## Install\n\n```sh\npip install flask-rest-jsonapi-next\n```\n\n## A minimal API\n\n```py\nfrom flask import Flask\nfrom flask_rest_jsonapi_next import Api, ResourceDetail, ResourceList\nfrom flask_sqlalchemy import SQLAlchemy\nfrom marshmallow_jsonapi.flask import Schema\nfrom marshmallow_jsonapi import fields\n\n# Create the Flask application and the Flask-SQLAlchemy object.\napp = Flask(__name__)\napp.config['DEBUG'] = True\napp.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'\ndb = SQLAlchemy(app)\n\n# Create model\nclass Person(db.Model):\n id = db.Column(db.Integer, primary_key=True)\n name = db.Column(db.String)\n\n# Create the database.\ndb.create_all()\n\n# Create schema\nclass PersonSchema(Schema):\n class Meta:\n type_ = 'person'\n self_view = 'person_detail'\n self_view_kwargs = {'id': '<id>'}\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\nclass PersonList(ResourceList):\n schema = PersonSchema\n data_layer = {'session': db.session,\n 'model': Person}\n\nclass PersonDetail(ResourceDetail):\n schema = PersonSchema\n data_layer = {'session': db.session,\n 'model': Person}\n\n# Create the API object\napi = Api(app)\napi.route(PersonList, 'person_list', '/persons')\napi.route(PersonDetail, 'person_detail', '/persons/<int:id>')\n\n# Start the flask loop\nif __name__ == '__main__':\n app.run()\n```\n\nThis example provides the following API structure:\n\n| URL | method | endpoint | Usage |\n| -------------------------- | ------ | ------------- | --------------------------- |\n| `/persons` | GET | person_list | Get a collection of persons |\n| `/persons` | POST | person_list | Create a person |\n| `/persons/<int:person_id>` | GET | person_detail | Get person details |\n| `/persons/<int:person_id>` | PATCH | person_detail | Update a person |\n| `/persons/<int:person_id>` | DELETE | person_detail | Delete a person |\n\n## Thanks\n\nFlask, marshmallow, marshmallow_jsonapi, sqlalchemy, Flask-RESTful and Flask-Restless\nare awesome projects. These libraries gave me inspiration to create\nflask-rest-jsonapi-next, so huge thanks to authors and contributors.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Flask extension to create REST web api according to JSONAPI 1.0 specification with Flask, Marshmallow and data provider of your choice (SQLAlchemy, MongoDB, ...)",
"version": "0.43.1",
"project_urls": {
"Documentation": "https://flask-rest-jsonapi-next.readthedocs.io/en/latest/",
"Source": "https://github.com/tadams42/flask-rest-jsonapi-next"
},
"split_keywords": [
"web",
"api",
"rest",
"jsonapi",
"flask",
"sqlalchemy",
"marshmallow"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1a02c80b07e368d13bffafb4b51dd9e68c7b06dc11e50e7600ab2524f3cfc68b",
"md5": "d8000e625a0f3b9a0d5a99a3c70f37a5",
"sha256": "ea55559693e3d7df834beb52c31e3039fb8830920bf09c0dae708be47879e152"
},
"downloads": -1,
"filename": "flask_rest_jsonapi_next-0.43.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d8000e625a0f3b9a0d5a99a3c70f37a5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 37022,
"upload_time": "2023-08-23T11:46:01",
"upload_time_iso_8601": "2023-08-23T11:46:01.890005Z",
"url": "https://files.pythonhosted.org/packages/1a/02/c80b07e368d13bffafb4b51dd9e68c7b06dc11e50e7600ab2524f3cfc68b/flask_rest_jsonapi_next-0.43.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4f4d734d2db45fb56ab977b5b81877f68c7b45befa3e3c053481062333fbb22c",
"md5": "5d64c954680205ec4889393fb7747ece",
"sha256": "4f3c4152ee7d5dac59a20630ca9d3dd89e4c7a49f7e9d8600dd42ccdd7da7efb"
},
"downloads": -1,
"filename": "flask-rest-jsonapi-next-0.43.1.tar.gz",
"has_sig": false,
"md5_digest": "5d64c954680205ec4889393fb7747ece",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 124179,
"upload_time": "2023-08-23T11:46:02",
"upload_time_iso_8601": "2023-08-23T11:46:02.987134Z",
"url": "https://files.pythonhosted.org/packages/4f/4d/734d2db45fb56ab977b5b81877f68c7b45befa3e3c053481062333fbb22c/flask-rest-jsonapi-next-0.43.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-23 11:46:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tadams42",
"github_project": "flask-rest-jsonapi-next",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "flask-rest-jsonapi-next"
}