What Are Resources?
When we talk about REST resources, we are referring to the components that make up a RESTful API. These resources are the building blocks of your API, and they represent the different entities or objects that can be accessed and manipulated through the API.
For example, we'll be creating an airline flights API. In our airline flights API, the resources could include flights, airports, passengers, and bookings. Each of these resources has its own unique URL that corresponds to a specific endpoint in the API.
To better understand what a resource is, let's take the example of flights in our airline API. A flight resource represents a single flight and holds information such as the departure and arrival airports, the flight number, the departure and arrival times, and the available seats. By accessing the flight resource through its designated URL, you can retrieve information about the flight, update its details, or delete the flight altogether.
But it's important to know that a resource could also be a collection (list) of flights. So it is not fixed to a single entity and not fixed to a physical entity either. For example a resource could be something which is ephemeral, like a booking transaction.
2 comments