Sign inDemoInstall


Package Overview
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies



Fully featured framework for fast, easy and documented API development with Flask




=========== Flask RESTX

.. image:: :target: :alt: Tests status .. image:: :target: :alt: Code coverage .. image:: :target: :alt: Documentation status .. image:: :target: :alt: License .. image:: :target: :alt: Supported Python versions .. image:: :target: :alt: Join the chat at .. image:: :target: :alt: Code style: black

Flask-RESTX is a community driven fork of Flask-RESTPlus <>_.

Flask-RESTX is an extension for Flask_ that adds support for quickly building REST APIs. Flask-RESTX encourages best practices with minimal setup. If you are familiar with Flask, Flask-RESTX 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-RESTX requires Python 3.8+.

On Flask Compatibility

Flask and Werkzeug moved to versions 2.0 in March 2020. This caused a breaking change in Flask-RESTX.

.. list-table:: RESTX and Flask / Werkzeug Compatibility :widths: 25 25 25 :header-rows: 1

* - Flask-RESTX version
  - Flask version
  - Note
* - <= 0.3.0
  - < 2.0.0
  - unpinned in Flask-RESTX. Pin your projects!
* - == 0.4.0
  - < 2.0.0
  - pinned in Flask-RESTX.
* - >= 0.5.0
  - < 3.0.0
  - unpinned, import statements wrapped for compatibility
* - == 1.2.0
  - < 3.0.0
  - pinned in Flask-RESTX.
* - >= 1.3.0
  - >= 2.0.0 (Flask >= 3.0.0 support)
  - unpinned, import statements wrapped for compatibility
* - trunk branch in Github
  - >= 2.0.0 (Flask >= 3.0.0 support)
  - unpinned, will address issues faster than releases.


You can install Flask-RESTX with pip:

.. code-block:: console

$ pip install flask-restx

or with easy_install:

.. code-block:: console

$ easy_install flask-restx

Quick start

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

.. code-block:: python

from flask import Flask
from flask_restx 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__':


Flask-RESTX is brought to you by @python-restx. Since early 2019 @SteadBytes, @a-luna, @j5awry, @ziirish volunteered to help @python-restx keep the project up and running, they did so for a long time! Since the beginning of 2023, the project is maintained by @peter-doggart with help from @ziirish. Of course everyone is welcome to contribute and we will be happy to review your PR's or answer to your issues.


The documentation is hosted on Read the Docs <>_

.. _Flask: .. _Swagger:


Want to contribute! That's awesome! Check out CONTRIBUTING.rst! <>_



Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc