Using basic Flask vs Flask-RESTful for API development : <p>I'm about to develop a REST API for our upcoming application. I have decided to use Python Flask for it. But at this point, I don't know which option to use. Should I be using the basic Flask package or Flask with Flask-RESTful extension. I've found some advantages and disadvantages in both. </p>

<p>Below is an example of two APIs doing the same thing but in Flask and Flask-RESTful:</p>

<p><strong>Flask version</strong>:</p>

<pre><code>from flask import Flask, jsonify

app = Flask(__name__)

usersList = ['Aaron', 'Bianca', 'Cat', 'Danny', 'Elena']

@app.route('/users', methods=['GET'])
def users():
    return jsonify({ 'users': [user for user in usersList] })

@app.route('/user/&lt;int:id&gt;', methods=['GET'])
def userById(id):
    return jsonify({ 'username': usersList[id]  })

@app.route('/user/&lt;string:name&gt;', methods=['GET'])
def getUserByName(name):
    # Show some user information
    return "Some info"

@app.route('/user/&lt;string:name&gt;', methods=['POST'])
def addUserByName(name):
    usersList.append(name)
    return jsonify({ 'message': 'New user added'  })

app.run()
</code></pre>

<p><strong>Flask-RESTful version</strong>:</p>

<pre><code>from flask import Flask
from flask_restful import Resource, Api

app = Flask(__name__)
api = Api(app)

usersList = ['Aaron', 'Bianca', 'Cat', 'Danny', 'Elena']

class UsersList(Resource):
    def get(self):
        return { 'users' : [ user for user in usersList  ] }, 200


class UserById(Resource):
    def get(self, id):
        return { 'username': usersList[id] }


class UserByName(Resource):
    def post(self, name):
        usersList.append(name)

        return { 'message': 'New user added'}


api.add_resource(UsersList, '/users')
api.add_resource(UserById, '/user/&lt;int:id&gt;')
api.add_resource(UserByName, '/user/&lt;string:name&gt;')

app.run()
</code></pre>

<p>Using Flask-RESTful, I cannot get a single resource to serve multiple related endpoints like <code>GET /user/&lt;int:id&gt;</code>, <code>GET /user/&lt;string:name&gt;</code>, <code>GET /user/&lt;int:id&gt;/friends</code> etc. And I don't know if creating new classes for simple sub-resources is a good practice because I'll probably end up with many classes. Due to this reason, I'm more inclined towards using just Flask since only functions are defined and the endpoints can be freely defined as per my needs.   </p>

<p>Keeping the above in mind, is it okay to create many classes for sub-resources in Flask-RESTful? Or am I better of using Flask? Or Flask-RESTful provides some really good advantages over Flask?</p>
