Generally speaking, RESTful API's are very good for representing resources and collections of resources.
And we are good, if we work with resource.
However, what should be done, when you need to expose API which does an action which doesn't create/update or delete a resource.
Couple of examples:
- You have an algorithm (as example add two numbers)
- You have an action which uses external system (as example send an email).
I saw two approaches:
Represent an action as a subresource
On one hand, it's straightforward. On other hand, it start smelling SOAPy (read RPC calls).
Represent an action as a standalone resource
This looks more RESTful. However, it doesn't feel right too (only one of CRUD actions is implemented). This resource actually doesn't have a representation.
I am not sure, may be there are other methods which I have missed.
The question is - "Is there a consensus on this subject? What is the preferred way to do it?"