What is the difference between a resource and an endpoint?

I heard how the "resource" and the "endpoint" all refer to the same thing. It seems that the resource is a newer term.

What is the difference between the two? "Resource" implies a RESTful project?

+116
rest api uri restful-architecture endpoint
Jun 01 '15 at 18:24
source share
6 answers

REST

A resource is a subset of a RESTful endpoint .

The endpoint itself is a place where you can access the service:

https://www.google.com # Serves HTML 8.8.8.8 # Serves DNS /services/service.asmx # Serves an ASP.NET Web Service 

A resource refers to one or more nouns represented in a namespace because people can easily understand:

 /api/users/johnny # Look up johnny from a users collection. /v2/books/1234 # Get book with ID 1234 in API v2 schema. 

All of the above can be considered as the endpoints of the service, but only the lower group will be considered as resources, if we say REST. The top group is not expressive in relation to the content that it provides.

A REST request is similar to a sentence consisting of nouns (resources) and verbs (HTTP methods):

  • GET (method) user named johnny (resource).
  • DELETE (method) book with identifier 1234 (resource).



Non-rest

An endpoint usually refers to a service, but a resource can mean many things. Here are some examples of resources that depend on the context in which they are used.

URL: Uniform Resource Locator

  • May be RESTful, but often not. In this case, the endpoint is almost synonymous.

Resource management

Dictionary

Something that might help you:

The library was a valuable resource, and he often used it.

Resources are natural substances such as water and wood that are valuable in supporting life:

[pl] The land has limited resources, and if we do not recycle them we use them.

Resources are also valuable things, such as money or property, that you can use when you need them:

[pl] The government does not have the resources to hire the number of teachers needed.




Morality

The term resource, by definition, has many nuances. It all depends on the context in which it is used.

+80
Jun 01 '15 at 18:38
source share

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 
+73
May 25 '18 at 8:01
source share

Perhaps my not-so-good answer, but here it goes.

Since I have worked with RESTful truly web services over HTTP, I have tried to distract people from using the term endpoint because it does not have a clear definition, and instead used the REST language, which represents resources and resource locations.

In my opinion, the endpoint is the term TCP. This is due to HTTP because part of the URL identifies the listening server.

So a resource is not a new term, I don’t think, I think that the endpoint has always been misappropriated, and we understand this when we deal with REST as an API style.

edit

I wrote about this on my blog.

https://medium.com/@lukepuplett/stop-saying-endpoints-92c19e33e819

+5
Sep 04 '18 at 11:03
source share

According to https://apiblueprint.org/documentation/examples/13-named-endpoints.html, the resource is the "common" storage location for this entity - for example, / Customers / 30654 / orders, while the endpoint is a specific action (HTTP- method) on this resource. Thus, a single resource can have multiple endpoints.

+1
Apr 08 '18 at 16:53
source share

Consider a server on which there is information about users, missions and their bonus points.

  1. Users and bonus points are resources.
  2. An endpoint can relate to more than one resource.
  3. Endpoints can be described using either a description or a full or partial URL

enter image description here

Source: API Endpoints vs. Resources

0
Sep 24 '19 at 12:28
source share

1. The description of the Resource resource refers to the information returned by the API.

2. Endpoints and methods Endpoints indicate how you access the resource, and the method indicates the allowed interactions (such as GET, POST or DELETE) with the resource.

Additional information: 3. Parameters Parameters are parameters that you can pass to the endpoint (for example, specify the response format or the amount returned) to influence the response.

4. Sample request A sample request includes an example request using an endpoint, showing some configured parameters.

5. Sample response and schema Sample response shows an example response from an example request; The response pattern defines all the possible elements in the response.

Source- Link

-one
Jun 13 '19 at 21:15
source share



All Articles