You now know about the components of a URL: protocol, domain, path, query parameters, and fragment identifiers. But that’s not all! URLs also have endpoints and resources. In this chapter, you’ll learn about endpoints and resources and how they differ from paths.

Let’s start with an example URL: https://api.example.com/users/12345?name=John Doe

The above URL has following components, and we document all of them if present:

  • Endpoint: https://api.example.com/users/12345?name=John Doe
  • Resource: /12345?name=John Doe

Let’s see everything in detail. Select the appropriate tabs for more information. For example, if you want all the relevant information on domain name, select the Endpoint tab.

Endpoint

An endpoint is a complete URL that can be used to access a resource. It includes the protocol (for example, HTTP or HTTPS), domain name, path, and query parameters (if any). The HTTP method is also typically included in the endpoint.

In our URL, the endpoint is: https://api.example.com/users/12345?name=John Doe.

This endpoint can be used to retrieve the user with the ID 12345 from the API exposed by api.example.com.

How to Identify an Endpoint?

To identify an endpoint, look for the following components in the URL:

  • Protocol (for example, HTTP or HTTPS)
  • Domain name
  • Path
  • Query parameter (if any)

For example, in the following URL, the endpoint is: https://api.example.com/users/12345:

HTTP GET /users/12345
Questions to ask yourself about endpoints:
  • What is the purpose of the endpoint in this API?
  • What is the full URL of the endpoint, including the protocol, domain, path, and query parameters?
  • What HTTP methods can be used with this endpoint (for example, GET, POST, PUT, DELETE)?
  • What type of data does this endpoint return (for example, JSON, XML)?
  • Are there any specific security considerations for this endpoint (for example, authentication or authorization requirements)?
  • Is the endpoint documented, and if so, where can you find the documentation?

Resource

A resource is a data object or entity that is exposed by an API. It can be anything from a single user to a complex product catalog. Resources are typically represented as JSON or XML objects in API responses.

For example, the following JSON object could represent a user resource:


{
  "id": 12345,
  "name": "John Doe",
  "email": "john.doe@example.com"
}

Resources can be accessed through endpoints. For example, the following endpoint could be used to retrieve the user with the ID 12345:

HTTP GET /users/12345

Resources can also be created, updated, and deleted through endpoints. For example, the following endpoint could be used to create a new user:

HTTP POST /users

How to Identify a Resource?

To identify a resource, look for the following in the URL:

  • Path
  • Query parameters (if any)

For example, in the following URL, the resource is the user with ID 12345:

https://api.example.com/users/12345
Questions to ask yourself about resources:
  • What is the purpose of this resource in the context of the API?
  • What data does this resource represent (for example, user, product, order)?
  • What is the structure and schema of this resource's data (for example, fields, attributes)?
  • How can you uniquely identify this resource (for example, ID, URL, or other key)?
  • What operations can you perform on this resource (for example, read, create, update, delete)?
  • Are there any relationships between this resource and other resources in the API?
  • What are the common use cases for accessing or modifying this resource?
  • Are there any specific access control or permissions associated with this resource?
  • How is this resource represented in API responses (for example, JSON, XML)?
Course completed
40%

Have an issue? Please provide specific feedback by reporting an issue.