In this chapter, you will learn the core skills of a programmer—the famous CRUD operations, which stand for Create
, Read
, Update
, and Delete
. These operations form the basis of most application functionalities, and through them, we will accomplish the following tasks:
- Add new words;
- Edit words;
- Paginated list of words;
- Word details;
- Delete words.
Introduction to RESTful
RESTful
is a design principle for web services based on the REST (Representational State Transfer)
architectural style. It is primarily used to create and access web resources and has the following characteristics:
- Resources: Every object in
RESTful
services is viewed as a resource that can be accessed throughURI
(Uniform Resource Identifier). For example,/words
can represent word resources; - HTTP Methods:
RESTful
services mainly useHTTP Method
for performing operations:GET
: Read resourcesPOST
: Create resourcesPUT
: Update resourcesPATCH
: Update partial resourcesDELETE
: Delete resources
- Representational State Transfer: Clients operate resources by requesting specific
URI
s, and servers return the representation of resources (usually in JSON or XML) in the response. - Uniform Interface: Standardized interface design allows different systems to communicate with each other.
These principles make RESTful
architecture simpler, more flexible, and scalable for Web
services. Here is an example of the CRUD
operations for words.
Operation | Method | URI | Description |
---|---|---|---|
Create (Create ) | POST | /words | Create a new word |
Read (Read ) | GET | /words | Get the list of all words |
Read (Read ) | GET | /words/{id} | Get a single word based on ID |
Update (Update ) | PUT | /words/{id} | Update the word with specified ID |
Update (Update ) | PATCH | /words/{id} | Update partial fields of the word with specified ID |
Delete (Delete ) | DELETE | /words/{id} | Delete the word with specified ID |