HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///
Total XP: 0|💻 apicreationmanipulation XP: 0

HTTP Methods (CRUD)

Master the core HTTP methods used in REST APIs: GET, POST, PUT, PATCH, and DELETE. Understand how they map to database CRUD operations and the critical concept of Idempotency.

LOADING ENGINE...

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

HTTP Verbs

Actions of the web.

Quick Quiz //

Which acronym perfectly maps the four primary database operations to the four primary HTTP methods?


If URLs are the nouns of the web, HTTP Methods are the verbs. They provide the exact action to perform on the targeted resource.

1The Verbs of REST

We established that REST URLs should be strictly nouns (e.g., /users). So how does the server know what action to perform on that noun? This is the job of HTTP Methods (often called HTTP Verbs). By attaching a specific verb to the request, you explicitly tell the server whether you want to Read, Create, Update, or Delete the resource. This maps perfectly to the database concept of CRUD.

+
// HTTP Methods map to CRUD

POST -> Create
GET -> Read
PUT -> Update
DELETE -> Delete
localhost:3000
localhost:3000
CRUD mapped: Verbs mapped securely to their corresponding database actions.

2GET: Reading Data

The GET method is used exclusively to request data from a specified resource. It is the most common HTTP method on the internet. Every time you type a URL into your browser and hit Enter, your browser performs a GET request under the hood. Crucially, GET requests are considered 'Safe' and 'Idempotent'. This means performing a GET request should NEVER alter or mutate data in the database. Browsers rely on this safety to cache GET responses aggressively.

+
// Fetching data without side effects:

GET /api/products
GET /api/products/42
localhost:3000
localhost:3000
Data retrieved: Safe, cacheable read operation completed without mutating the database.

3POST: Creating Data

The POST method is used to send data to the server to create a new resource. Unlike GET, POST requests carry a 'Body' (usually a JSON payload containing the new data). POST requests are NOT idempotent. This means if you execute the exact same POST request 10 times, the server will create 10 distinct, duplicate records in the database. When you submit a signup form, it sends a POST request. The browser knows this isn't safe to repeat blindly.

+
POST /api/users
Content-Type: application/json

{
  "name": "Alice"
}
localhost:3000
localhost:3000
Resource created: Non-idempotent operation safely processed the payload.

4PUT vs PATCH: Updating Data

When you need to modify existing data, you use PUT or PATCH. While often used interchangeably by junior developers, they have a strict semantic difference. PUT is a complete replacement; it overwrites the entire resource. If you omit a field in a PUT request, that field is deleted. PATCH is a partial update; it only modifies the specific fields you send, leaving the rest of the object untouched. Modern architectures lean heavily on PATCH for safety.

+
// Existing: { id: 1, name: "A", age: 20 }

PUT /users/1 { name: "B" }
// Result: { id: 1, name: "B" } (age lost!)

PATCH /users/1 { name: "B" }
// Result: { id: 1, name: "B", age: 20 }
localhost:3000
localhost:3000
Update applied: Use PATCH to safely mutate partial structures without data loss.

5DELETE: Removing Data

The DELETE method is straightforward: it removes a specified resource from the server. Like GET, a DELETE request typically does not contain a body payload. The ID of the resource to be deleted is usually passed directly in the URL (e.g., /users/42). It is also idempotent; deleting a resource once removes it, and firing that same delete request again just results in a 404 (because it's already gone), leaving the server in the exact same state.

+
// Securely wipe the record:

DELETE /users/42
localhost:3000
localhost:3000
Resource destroyed: Entity purged idempotently from the backend cluster.

?Frequently Asked Questions

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Lesson Glossary

[01]CRUD

Create, Read, Update, Delete. The four basic functions of persistent storage, which map directly to POST, GET, PUT/PATCH, and DELETE.

Code Preview
The Database Actions

[02]Idempotent

An operation that can be applied multiple times without changing the result beyond the initial application (e.g., PUT, DELETE).

Code Preview
The Safe Repeat

[03]Payload / Body

The data sent by the client to the server in an HTTP request, typically formatted as JSON, used heavily in POST and PUT/PATCH requests.

Code Preview
The Cargo

[04]GET

The HTTP method used exclusively to read or retrieve data without causing any side effects on the server.

Code Preview
The Reader

[05]PATCH

The HTTP method used for applying partial modifications to a resource, contrasting with PUT's full replacement.

Code Preview
The Surgeon

Continue Learning

Go Deeper

Related Courses