Why RESTful API rules are not enough or good for you to design good apis?

RESTFUL API trys to use http protocol to operate application resources.
But application resources have more methods needed than HTTP methods, which are created for http protocol.

RESTful APIs can not fully describe some apis you really want.

For you …


This content originally appeared on DEV Community and was authored by Eric

RESTFUL API trys to use http protocol to operate application resources.
But application resources have more methods needed than HTTP methods, which are created for http protocol.

RESTful APIs can not fully describe some apis you really want.

For you may want apis like these:

/user/login
/user/logout
/user/like
/user/dislike
/user/send
/user/receive

instead of just

/users/:id

Those methods PUT, GET, DELETE, can not describe such actions. So with RESTful apis, you can not meet the project apis' needs.

Alt Text

The real apis need not only resource apis, but logic apis as well.
An api principle only for resource will not be suitable for logic api.

So RESTful APIs is not enough for your apis.

You need logic apis which must have actions, for example.

POST /user/login 

instead of

PUT /users/:id

There is always requirement for logic apis.
Regardless you should use graphql or restful apis.

The try to unify apis for a project is not a good idea.
Try to separate data transfer from logic operations may be a good idea.

If you are designing an api set for your project, you may design apis into at least two subsets: the data retrieving apis (with restful/graphql apis), the logic/business operational apis(to relect the real needs).

RESTful apis is not a very good api design principle.
It in fact mixes business applications with networking protocol.

You can use only GET/POST for data apis if you add some extra query info to representing you actions. for example:

POST /users/:id?action=update
POST /users/:id?action=delete

Then you have separated your application logic from http methods now.


This content originally appeared on DEV Community and was authored by Eric


Print Share Comment Cite Upload Translate Updates
APA

Eric | Sciencx (2021-03-14T14:41:59+00:00) Why RESTful API rules are not enough or good for you to design good apis?. Retrieved from https://www.scien.cx/2021/03/14/why-restful-api-rules-are-not-enough-or-good-for-you-to-design-good-apis/

MLA
" » Why RESTful API rules are not enough or good for you to design good apis?." Eric | Sciencx - Sunday March 14, 2021, https://www.scien.cx/2021/03/14/why-restful-api-rules-are-not-enough-or-good-for-you-to-design-good-apis/
HARVARD
Eric | Sciencx Sunday March 14, 2021 » Why RESTful API rules are not enough or good for you to design good apis?., viewed ,<https://www.scien.cx/2021/03/14/why-restful-api-rules-are-not-enough-or-good-for-you-to-design-good-apis/>
VANCOUVER
Eric | Sciencx - » Why RESTful API rules are not enough or good for you to design good apis?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/14/why-restful-api-rules-are-not-enough-or-good-for-you-to-design-good-apis/
CHICAGO
" » Why RESTful API rules are not enough or good for you to design good apis?." Eric | Sciencx - Accessed . https://www.scien.cx/2021/03/14/why-restful-api-rules-are-not-enough-or-good-for-you-to-design-good-apis/
IEEE
" » Why RESTful API rules are not enough or good for you to design good apis?." Eric | Sciencx [Online]. Available: https://www.scien.cx/2021/03/14/why-restful-api-rules-are-not-enough-or-good-for-you-to-design-good-apis/. [Accessed: ]
rf:citation
» Why RESTful API rules are not enough or good for you to design good apis? | Eric | Sciencx | https://www.scien.cx/2021/03/14/why-restful-api-rules-are-not-enough-or-good-for-you-to-design-good-apis/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.