ChatGPT解决这个技术问题 Extra ChatGPT

What is an Endpoint?

I have been reading about OAuth and it keeps talking about endpoints. What is exactly an endpoint?


T
Tomeg

Come on guys :) We could do it simpler, by examples:

/this-is-an-endpoint
/another/endpoint
/some/other/endpoint
/login
/accounts
/cart/items

and when put under a domain, it would look like:

https://example.com/this-is-an-endpoint
https://example.com/another/endpoint
https://example.com/some/other/endpoint
https://example.com/login
https://example.com/accounts
https://example.com/cart/items

Can be either http or https, we use https in the example.

Also endpoint can be different for different HTTP methods, for example:

GET /item/{id}
PUT /item/{id}

would be two different endpoints - one for retrieving (as in "cRud" abbreviation), and the other for updating (as in "crUd")

And that's all, really that simple!


Upvoted for mentioning that different HTTP methods define separate endpoints.
Matthew 20:16 KJV - So the last shall be first (..) :)
It's too bad, Stack Exchange does not show this answer as the first or second answer. For me, it was way down the list and definitely the best one since I didn't know if a whole set of actions and controllers was considered an endpoint, or a single action in a single controller defined an endpoint. This answer told me that it was the latter.
@Tomeg one question if I have to URLs hitting same implementation are they considered as same endpoint or different? for e.g. GET public/v1/operation and internal/v1/Opearation both hits same implementation then can we consider them as same end point?
@Parth the endpoint generally is what is supposed to be called by a request, what you provide as an interface to your API consumers - what you tell them to use. So then in this example your implementation handles two endpoints (because you provided your API consumer/user with two ways to call something). But I just wrote that it is "generally" and if there is some person who insists on calling endpoint a bit different (e.g. in your example someone would insist to say this is one endpoint), then you say "OK, whatever, these are just words! I am happy enough that we simply understand each other"
P
Paul Osman

All of the answers posted so far are correct, an endpoint is simply one end of a communication channel. In the case of OAuth, there are three endpoints you need to be concerned with:

Temporary Credential Request URI (called the Request Token URL in the OAuth 1.0a community spec). This is a URI that you send a request to in order to obtain an unauthorized Request Token from the server / service provider. Resource Owner Authorization URI (called the User Authorization URL in the OAuth 1.0a community spec). This is a URI that you direct the user to to authorize a Request Token obtained from the Temporary Credential Request URI. Token Request URI (called the Access Token URL in the OAuth 1.0a community spec). This is a URI that you send a request to in order to exchange an authorized Request Token for an Access Token which can then be used to obtain access to a Protected Resource.

Hope that helps clear things up. Have fun learning about OAuth! Post more questions if you run into any difficulties implementing an OAuth client.


Why not just call it (i.e. so called "endpoint") a "base URI"? Is there a fundamental difference between an "endpoint" and a "base URI"? Thanks.
@Xlsx It depends on the implementation. An example request could be to GET "/users?name=admin" or "/users/admin". You could do one or the other or both or neither.
Not useful since OP asked for "general endpoints", not specifically OAuth. I'm now confused.
@Withheld an endpoint is a URI + a request method (GET, POST, PUT, DELETE, etc.)
D
David M

It's one end of a communication channel, so often this would be represented as the URL of a server or service.


So, what is the difference between an URL and an endpoint? You say "often this would be represented as the URL", so there are cases when it's not by represented by an URL? So, what is it represented by in those cases? Also, in the answer above, they say that endpoints can have the same URL but differ in the HTTP method. That explanation is inconsistent with yours, apparently. You should edit your answer to clarify that.
L
Lemuel Uhuru

An endpoint is a URL pattern used to communicate with an API.


Can you provide an example of what you mean by "URL pattern"? And what the heck is an API then? Also, if an endpoint is just a URL pattern, then why does this answer say that GET /item/{id} is a different endpoint than PUT /item/{id}? So, an endpoint is not just a "URL pattern", but should include also the HTTP request method?
D
Daniel Serodio

Endpoint, in the OpenID authentication lingo, is the URL to which you send (POST) the authentication request.

Excerpts from Google authentication API

To get the Google OpenID endpoint, perform discovery by sending either a GET or HEAD HTTP request to https://www.google.com/accounts/o8/id. When using a GET, we recommend setting the Accept header to "application/xrds+xml". Google returns an XRDS document containing an OpenID provider endpoint URL.The endpoint address is annotated as:

<Service priority="0">
<Type>http://specs.openid.net/auth/2.0/server</Type> 
<URI>{Google's login endpoint URI}</URI> 
</Service>

Once you've acquired the Google endpoint, you can send authentication requests to it, specifying the appropriate parameters (available at the linked page). You connect to the endpoint by sending a request to the URL or by making an HTTP POST request.


J
Justin Franks

An endpoint is the 'connection point' of a service, tool, or application accessed over a network. In the world of software, any software application that is running and "listening" for connections uses an endpoint as the "front door." When you want to connect to the application/service/tool to exchange data you connect to its endpoint


Defining endpoint in terms of "connection point", which is even more vague, is far from a good idea, if the goal of this answer was to clear things up.
C
Cleber Jorge Amaral

Short answer: "an endpoint is an abstraction that models the end of a message channel through which a system can send or receive messages" (Ibsen, 2010).

Endpoint vs URI (disambiguation)

The endpoint is not the same as a URI. One reason is because a URI can drive to different endpoints like an endpoint to GET, another to POST, and so on. Example:

@GET /api/agents/{agent_id} //Returns data from the agent identified by *agent_id*
@PUT /api/agents/{agent_id} //Update data of the agent identified by *agent_id*

Endpoint vs resource (disambiguation)

The endpoint is not the same as a resource. One reason is because different endpoints can drive to the same resource. Example:

@GET /api/agents/{agent_id} @Produces("application/xml") //Returns data in XML format
@GET /api/agents/{agent_id} @Produces("application/json") //Returns data in JSON format

I
IKriKan

The term Endpoint was initially used for WCF services. Later even though this word is being used synonymous to API resources, REST recommends to call these URI (URI[s] which understand HTTP verbs and follow REST architecture) as "Resource".

In a nutshell, a Resource or Endpoint is kind of an entry point to a remotely hosted application which lets the users to communicate to it via HTTP protocol.


i
ismael

The endpoint of the term is the URL that is focused on creating a request. Take a look at the following examples from different points:

/api/groups/6/workings/1
/api/v2/groups/5/workings/2
/api/workings/3

They can clearly access the same source in a given API.


N
NicholasKyleHoffman

API stands for Application Programming Interface. It is a way for your application to interact with other applications via an endpoint. Conversely, you can build out an API for your application that is available for other developers to utilize/connect to via HTTP methods, which are RESTful. Representational State Transfer (REST):

GET: Retrieve data from an API endpoint.

PUT: Update data via an API - similar to POST but more about updating info.

POST: Send data to an API.

DELETE: Remove data from given API.

PATCH: Update data.