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

李白字一日
2 min readMar 14, 2021

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:

instead of just

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

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.

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:

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

Originally published at https://dev.to on March 14, 2021.

--

--