HTTP Methods Explained: The Way of Communication for APIs

Shubham Patel
PM for 5yo
Published in
4 min readSep 3, 2024

In the previous posts, we discussed the concept of API. I hope this is easy to understand. In this post, we will discuss how computers ask each other to do things using something called HTTP Methods. Imagine you are sending different types of letters to your friend to ask for different things. That’s what HTTP Methods are like—they are ways for one computer to ask another computer to do something.

Essentially, these methods are different types of instructions or commands that a client can send to a server to perform various actions, such as retrieving, submitting, updating, or deleting.

Let’s look at 9 different “methods” that our virtual machines (computers :D) use to talk to each other. We’ll imagine that you are the client placing requests and the server is your pen pal in the virtual realm.

1. GET Method

Think of a “GET” letter as a simple request like, “Can you please send me the list of toys?” This letter doesn’t change anything; it just asks for information. If the server has the list, they send it back (like getting a “200 OK” message), but if they don’t, they say, “404 Not Found!” It’s like a way to check what’s available.

Image created using Ideogram

2. POST Method

Imagine writing a “POST” letter asking someone to add a new toy to your shared collection. “Hey, can you add a new Hot Wheels to our toy box?” Your friend gets the letter and buys the toy car to add to the collection. But if you send the same “POST” again, you end up with two robots! This method creates new things, so be careful not to duplicate them.

3. PUT Method

A “PUT” method is when you want to change everything about a toy. “Hey, please replace the old Camaro with this new Mustang.” Your server friend will throw away the old car and put the new one in. Every time you send a PUT, your friend will do the same thing — no surprises!

4. PATCH Method

Now, if you only want to change part of the toy, like saying, “Hey, just change the wheels of my red car to blue,” that’s a “PATCH” letter. It doesn’t replace the whole car, just the part you mentioned. It’s a small change, like fixing one part instead of changing everything.

5. DELETE Method

A “DELETE” letter is for when you don’t want a toy anymore: “Hey, can you please remove my broken robot from the toy collection?” Your server pen pal will take it out, and it’s gone. Now, even if you ask again, they will say, “It’s already gone!” As in the name, “DELETE” is a way to clean up!

6. HEAD Method

The “HEAD” letter is like peeking at a list without opening it. You ask, “Can you tell me how many toys are on the list without showing them?” The server just sends back the number, not the actual list. It’s quick and doesn’t waste time.

7. OPTIONS Method

An “OPTIONS” letter is like asking, “What can I do?” Your server friend tells you all the things you’re allowed to ask for, like a menu of choices. It helps you understand what actions are possible on this API.

8. TRACE Method

A “TRACE” letter is for checking if your message is getting through correctly. Have you seen folks saying copy on their walkie-talkies in the movies? It’s like sending a letter to your friend that says, “Can you copy this letter and send it back to me?” Your friend will send back exactly what you wrote. This helps you see if anything got lost or changed on the way.

9. CONNECT Method

A “CONNECT” letter is like building a pipeline between you and your friend so you can pass secret messages back and forth safely. It helps set up a special connection to keep everything private and secure, like passing notes through a hidden tunnel.

Conclusion:

These are the most popular 9 ways computers ask each other to do things, just like writing different kinds of letters to your friends! Each method has a special job, whether it’s asking for information, adding something new, changing something, or even deleting something. Remember, understanding these methods is important in understanding the technology and functioning of APIs.

As a product manager, understanding the basics of technology goes a long way. You will have to interact and ideate with engineers and developers daily. Knowing the basics first-hand is always suitable for making better product decisions and creating an impeccable user experience.

This blog post is part of a series — Technology for New PMs.

--

--