Fully featured framework for fast, easy and documented API development with Flask
Clone or download
Latest commit a8f3582 Oct 1, 2018
Failed to load latest commit information.
doc Merge pull request #255 from ziirish/master Oct 1, 2018
examples Todo model's id readonly property typo fix Jun 20, 2018
flask_restplus Merge pull request #255 from ziirish/master Oct 1, 2018
requirements use environment markers to specify enum34 requirement to fix pip install May 22, 2018
tests Merge pull request #255 from ziirish/master Oct 1, 2018
.editorconfig Added editorconfig Jan 15, 2017
.gitignore Ignore benchmark and profiling results Oct 24, 2017
.pyup.yml Added pyup config Oct 24, 2017
.travis.yml Disable Python 3.3 build on Travis Oct 24, 2017
AUTHORS.rst Added namespace parsing of authorizations Mar 6, 2018
CHANGELOG.rst Ensure basePath is always a path Sep 28, 2018
CONTRIBUTING.rst Add a line about the changelog in contributing guidelines Oct 19, 2016
LICENSE Change license to BSD 3 Clause May 7, 2018
MANIFEST.in Upgrade to Swagger UI 3.4.0 (fix #338) Oct 24, 2017
README.rst Update to version 0.12.2.dev for next development cycle Sep 28, 2018
bumpr.rc Fix bumpr.rc Sep 27, 2018
coverage.rc Initial import Aug 14, 2014
package.json Change license to BSD 3 Clause May 7, 2018
readthedocs.pip Misc fixes Jan 17, 2016
setup.cfg Port benchmarks to pytest-benchmark May 16, 2017
setup.py use environment markers to specify enum34 requirement to fix pip install May 22, 2018
tasks.py Fix assets command May 16, 2018
tox.ini Drop support for Python 3.3 Oct 23, 2017
travis-bench-after-success.sh Fix benchmark May 16, 2017


Flask RestPlus

Build status Code coverage Documentation status License Supported Python versions Join the chat at https://gitter.im/noirbizarre/flask-restplus

Flask-RESTPlus is an extension for Flask that adds support for quickly building REST APIs. Flask-RESTPlus encourages best practices with minimal setup. If you are familiar with Flask, Flask-RESTPlus should be easy to pick up. It provides a coherent collection of decorators and tools to describe your API and expose its documentation properly using Swagger.


Flask-RestPlus requires Python 2.7 or 3.4+.


You can install Flask-Restplus with pip:

$ pip install flask-restplus

or with easy_install:

$ easy_install flask-restplus

Quick start

With Flask-Restplus, you only import the api instance to route and document your endpoints.

from flask import Flask
from flask_restplus import Api, Resource, fields

app = Flask(__name__)
api = Api(app, version='1.0', title='TodoMVC API',
    description='A simple TodoMVC API',

ns = api.namespace('todos', description='TODO operations')

todo = api.model('Todo', {
    'id': fields.Integer(readOnly=True, description='The task unique identifier'),
    'task': fields.String(required=True, description='The task details')

class TodoDAO(object):
    def __init__(self):
        self.counter = 0
        self.todos = []

    def get(self, id):
        for todo in self.todos:
            if todo['id'] == id:
                return todo
        api.abort(404, "Todo {} doesn't exist".format(id))

    def create(self, data):
        todo = data
        todo['id'] = self.counter = self.counter + 1
        return todo

    def update(self, id, data):
        todo = self.get(id)
        return todo

    def delete(self, id):
        todo = self.get(id)

DAO = TodoDAO()
DAO.create({'task': 'Build an API'})
DAO.create({'task': '?????'})
DAO.create({'task': 'profit!'})

class TodoList(Resource):
    '''Shows a list of all todos, and lets you POST to add new tasks'''
    def get(self):
        '''List all tasks'''
        return DAO.todos

    @ns.marshal_with(todo, code=201)
    def post(self):
        '''Create a new task'''
        return DAO.create(api.payload), 201

@ns.response(404, 'Todo not found')
@ns.param('id', 'The task identifier')
class Todo(Resource):
    '''Show a single todo item and lets you delete them'''
    def get(self, id):
        '''Fetch a given resource'''
        return DAO.get(id)

    @ns.response(204, 'Todo deleted')
    def delete(self, id):
        '''Delete a task given its identifier'''
        return '', 204

    def put(self, id):
        '''Update a task given its identifier'''
        return DAO.update(id, api.payload)

if __name__ == '__main__':


The documentation is hosted on Read the Docs