A REST API, also referred to as a RESTful API, is a type of application programming interface (API) that adheres to the principles of the REST architectural style, enabling interaction with RESTful web services. REST, which stands for Representational State Transfer, was developed by computer scientist Roy Fielding.

How to identify resources in Rest Api?

Using GET Request

Designing a RESTful web service begins with identifying resources from use cases and service descriptions. This post will guide you through this process by dividing the topic into multiple sections: problem statement, solution, case studies, and examples.

Problem Statement

You need to identify resources from use cases and a description of the web service.


To identify resources, analyze your use cases to find domain nouns that can be manipulated using “create,” “read,” “update,” or “delete” operations. Designate each noun as a resource. Implement the operations with the following HTTP methods:

  • POST for creating a resource
  • GET for reading a resource
  • PUT for updating a resource
  • DELETE for deleting a resource

Precautions While Extracting Resources

Consider the following precautions when extracting resources:

  1. Database Information Management:
    • Resources on the web correspond to information managed by the database.
    • Avoid directly exposing the database model as a resource without careful consideration, as it might contain sensitive fields not intended for clients.
  2. Different Information Types in the Same Table:
    • When different types of information are managed by the same database table, consider publishing them as separate resources.
    • Although they share a data structure, they may represent fundamentally different information and should be reviewed closely.
  3. Event-Operated Information:
    • In a RESTful web service, information manipulated by an event should be extracted as a resource.
    • The event itself, such as workflow actions (approve, deny, return), should not be a resource. Instead, extract the information related to the workflow status or the workflow itself.

Case Study 1: Photo Management Service

Consider a web service for managing photos. Clients need to:

  • Upload a new photo
  • Replace an existing photo
  • View a photo
  • Delete a photo

In this scenario, “photo” is an entity in the application domain. The actions a client can perform are mapped to HTTP methods as follows:

  • GET: Retrieve a photo
  • PUT: Update a photo
  • DELETE: Remove a photo
  • POST: Create a new photo

This approach illustrates why REST is often seen as suitable for CRUD-style (Create, Read, Update, Delete) applications.

Case Study 2: User Management System

Consider a User Management System that requires CRUD operations for the User entity. Below are standard RESTful API endpoints for this system:

  • GET: Retrieve a list of users
    Path: /api/v1/users
  • GET: Retrieve a specific user by ID
    Path: /api/v1/users/100
  • POST: Create a new user
    Path: /api/v1/users
  • DELETE: Remove a user by ID
    Path: /api/v1/users/101
  • PUT: Update a user by ID
    Path: /api/v1/users/102
  • POST: Activate a user
    Path: /api/v1/users/active
  • POST: Deactivate a user
    Path: /api/v1/users/deactive

By following these guidelines and best practices, you can effectively identify and manage resources in your RESTful web service.

Also watch : Is there a significant oversaturation of aspiring MERN or React developers competing for junior positions?

Leave a Reply

Your email address will not be published. Required fields are marked *