DEV Community

Discussion on: Explain HTTP Verbs like I'm Five

Collapse
 
amcaplan profile image
Ariel Caplan • Edited

You can think of URLs as markers of cabinets and shelves in a big set of cabinets.

GET means: Fetch me the thing in the place where the URL points. GET /widgets tells me I want to access all the items in the cabinet where widgets are stored. GET /widgets/5 tells me I want the widget on shelf #5 in the cabinet. (There may be a lot of shelves in the cabinet!)

POST means: Add a new shelf with a new thing in this cabinet. For example, POST /widgets means add a thing to the widgets cabinet.

PUT means: Replace a thing in this cabinet. For example, PUT /widgets/5 means replace the thing on widget shelf #5 with this new thing I'm sending you.

PATCH means: Make some changes to a thing in this cabinet. PATCH /widgets/5 means "Here's a set of changes to make to the widget on shelf #5." There's no standard way of describing those changes.

DELETE means: Remove a thing from the cabinet. For example, DELETE /widgets/5 means throw out whatever is on shelf #5 in the widgets cabinet.