in this example we are not dealing with any resource
Resource
, in the context of REST, means something specific. Here is how Fielding describes resource:
The key abstraction of information in REST is a resource. Any information that can be named can be a resource: a document or image, a temporal service (e.g. "today's weather in Los Angeles"), a collection of other resources, a non-virtual object (e.g. a person), and so on. In other words, any concept that might be the target of an author's hypertext reference must fit within the definition of a resource.
So from the framework of REST, it is perfectly reasonable to say that /week?date=2020/04/14
identifies a resource whose representation describes a calendar week.
Since the HTTP request in this case has effectively read only semantics (aka "safe" semantics) -- we're not expecting the server to change in any way -- the natural fit for this request would be to use GET
.
GET /week?date=2020/04/14
As a general rule, anything that is just returning the result of a calculation should use GET, with the parameters provided by the client encoded into the identifier of the resource (as we did with GET forms on the web).
The exception to this are those cases where the parameters are so large/numerous that your queries get crippled by de facto limits on URI length. In those cases, you use POST, sacrificing easy caching for getting the job done at all.