I'm studying about web APIs and REST and the book I'm reading says the following:
The Web is built around three main concepts: features, URIs, and representations.
A resource is anything that has a URI. A feature itself is a conceptual mapping for one or more entities
That left me quite in doubt. I always found that a resource was the entity itself. For example, we have a index.html
file that has a servidor.com/index.html
URI, I thought the resource itself would be this file.
Another example of the same type would be a Cliente
object that can be retrieved from a database through a URI containing its servidor.com/api/clientes/123
ID, again I thought the resource would be the returned object.
On the other hand, I know that a certain URI can simply receive data and perform some kind of action on the server, without returning or modifying a persisted entity on the server. The book even includes an example of this.
A feature can be a service that provides an interface to anything like a catalog, a device (e.g., a printer), a wireless opener for a garage door ...
In both the printer and the garage door, there is no entity on the server. The URI will simply allow some code to be executed.
What does a feature mean to be a conceptual mapping for one or more entities?
Editing: Thinking a little about this I came up with the following way of thinking: a resource is anything that can be reached from a URL. For example, the homepage of a website, or a client with a certain ID. The resource is not the index.html
file itself, nor the JSON object containing the client data, because these two things are just the state of it at that moment (they are representations), so the resource is actually the concept behind it of these states: both the page and the client.
Is this what a feature is? If yes, why can this be considered a conceptual mapping for one or more entities?