Remember that with the REST API, all this applies to your point of view.
Two key concepts in the REST API are endpoints and resources (entities). It is clear that the endpoint either returns resources via GET, or accepts resources through POST and PUT, etc. (Or a combination above).
It is assumed that with the help of POST, the data you send may or may not lead to the creation of a new resource and related endpoints, which, most likely, will not "live" under the POSTed url. In other words, when you send POST, you send data for processing. The POST endpoint is not where the resource can usually be found.
Quotation from RFC 2616 (with inappropriate parts omitted and highlighted relevant parts):
9.5 POST
The POST method is used to request that the source server accept the object enclosed in the request as a new subordinate resource identified by the Request-URI in the query string. POST is designed to allow a uniform method to cover the following functions:
- ...
- Providing a data block, for example, the result of submitting a form, to the data processing process
- ...
...
An action performed by the POST method may not result in a resource that can be identified by a URI . In this case, either 200 (OK) or 204 (No content) is the corresponding response status, depending on whether the response includes an object that describes the result .
If the resource was created on the source server, the response MUST be 201 (created) ...
We are used to endpoints and resources representing "things" or "data", whether it is a user, a message, a book - regardless of what the problem area dictates. However, the endpoint may also expose another resource — for example, search results.
Consider the following example:
GET /books?author=AUTHOR POST /books PUT /books/ID DELETE /books/ID
This is a typical REST CRUD. However, what if we added:
POST /books/search { "keywords": "...", "yearRange": {"from": 1945, "to": 2003}, "genre": "..." }
There is nothing superfluous at this endpoint. It receives data (entity) in the form of a request body. This data is the search criteria - DTO, like any other. This endpoint creates a resource (object) in response to a query: Search results . The search result resource is temporary, immediately transferred to the client without redirecting, and is not exposed to any other canonical URL.
It is still REST, except that entities are not books - the query object is the criteria for finding books, and the response object is the search results in books.