The terms resource and endpoint are often used synonymously. But in reality they do not mean the same thing.
The term endpoint is focused on the URL that is used to send the request.
The term resource is focused on the data set that is returned by the request.
Now different endpoints can often access the same resource.
Also, the same endpoint may return different resources depending on the query string.
Let's see a few examples:
Different endpoints access the same resource
Look at the following examples of different endpoints:
/api/companies/5/employees/3 /api/v2/companies/5/employees/3 /api/employees/3
Obviously, they can all access the same resource in this API.
Also, the existing API can be completely changed. This can lead to the emergence of new endpoints that will access the same old resources using completely new and different URLs:
/api/employees/3 /new_api/staff/3
One endpoint access to different resources
If your endpoint returns a collection, you can implement search / filtering / sorting using query strings. As a result, all of the following URLs use the same endpoint ( /api/companies ), but they can return different resources (or collections of resources, which are, by definition, resources themselves):
/api/companies /api/companies?sort=name_asc /api/companies?location=germany /api/companies?search=siemens
Jpsy May 25 '18 at 8:01 2018-05-25 08:01
source share