Using basic Flask vs Flask-RESTful for API development Using basic Flask vs Flask-RESTful for API development flask flask

Using basic Flask vs Flask-RESTful for API development


REST is a pretty flexible architecture, but there's a few points worth thinking about in your approach using just Flask, which Flask-RESTful is encouraging you away from:

  1. By convention, a GET on a single resource (e.g. /users/1234) is by a unique identifier for the resource. The name of a user can't be guaranteed to be unique, so it would be risky to have it as an identifier within the URI (e.g. /users/joe).

  2. When you access users within a collection, it's better to stick with the plural noun throughout (not, as you show in your Flask example, /user/...).

  3. When you're creating and using POST, unless your client is specifying the id (in which case it has to be able to guarantee uniqueness, so pretty much the only valid id would be a UUID), you can post to just the collections URI (e.g. /users/).

Either will work, but with Flask-RESTful you'll find that when you follow those guidelines, your class matches your resources much more closely and you won't see the proliferation of classes you describe.

A very similar use case is demonstrated at https://flask-restful.readthedocs.io/en/latest/quickstart.html#full-example.


I would recommend you to use Flask-RESTplus instead, that will give you full Swagger support.

In regards of just using Flask, I would say getting the Swagger functionality is a big one to choose Flask-Restplus also.


Not sure why no one mentioned the fact that standard Flask is also REST-API enabled i.e. you really don't need to import the REST package to avail something that is missing in standard Flask package.

You are absolutely free to choose whichever you want depending upon your comfort level and any method chosen shouldn't affect your end-result functionality.

I understand that we can be inclined towards using something that is meant for a specific job but sometimes, in coding world, comfort matters regardless of how many extra lines of code you have to write.

Hope this answers your query.