API Fundamentals Course
API Fundamentals
/
Intermediate

PATCH

Definition

An HTTP method used to apply partial modifications to a resource.

Explain Like I'm New

While PUT replaces the entire car, PATCH just replaces the tires. You only send the exact specific pieces of data that you want to change, and the server leaves everything else completely alone.

Real World Example

A user clicks a 'Like' button. You don't want to download their entire profile and upload it again (PUT). You just send a PATCH request saying `{ "likes": +1 }`.

Common Use Cases

  • •Partial updates
  • •Saving bandwidth

Interactive Example

Loading...
Console output will appear here...

Interview Questions

basic

  • If you only want to update a user's email address, which method should you use: PUT or PATCH?

intermediate

  • Why is PATCH generally preferred over PUT in modern REST APIs?

Flash Cards

Question

PUT or PATCH?

Click to reveal answer
Answer

PATCH. You are partially updating the resource, not replacing the entire user object.

Question

Why preferred?

Click to reveal answer
Answer

Bandwidth and complexity. If an object has 50 fields, sending a PUT requires transmitting all 50 fields over the network just to change 1. PATCH only requires sending the 1 field.