Top 9 HTTP Request Methods - rnakidi/dsa GitHub Wiki
Top 9 HTTP Request Methods Every Developer Should Know!
Whether you're building APIs, designing web services, or debugging applications, understanding HTTP request methods is a must-have skill for modern developers.
This infographic breaks down the 9 most commonly used HTTP methods, their purposes, and practical examples of how they work.
🔑 Here's What You Should Know: 1️⃣ GET Used to retrieve data from a server. 👉 Example: GET /v1/products/iphone The server responds with the requested data, such as details about an iPhone product. Ideal for fetching single items or lists of resources.
2️⃣ POST Used to create new resources. 👉 Example: POST /v1/users Send a JSON payload (e.g., user details) to the server, and it creates a new resource.
3️⃣ PUT Used to completely replace an existing resource. 👉 Example: PUT /v1/users/123 Send the full updated data for a user, and the server replaces the old resource with the new one.
4️⃣ PATCH Used to partially update an existing resource. 👉 Example: PATCH /v1/users/123 Send only the fields you want to update (e.g., updating just an email).
5️⃣ DELETE Used to remove a resource. 👉 Example: DELETE /v1/users/123 The server deletes the specified user.
6️⃣ HEAD Fetches headers for a resource without downloading the full body. 👉 Example: HEAD /v1/products/iphone Great for checking metadata or verifying resource availability.
7️⃣ OPTIONS Used to discover the HTTP methods supported by an endpoint. 👉 Example: OPTIONS /v1/users The server responds with the allowed methods (e.g., GET, POST, DELETE, etc.).
8️⃣ CONNECT Establishes a two-way connection (like for tunneling through a proxy). 👉 Example: CONNECT example.com:80
9️⃣ TRACE Used for debugging; it performs a loop-back test to verify communication. 👉 Example: TRACE /index.html
Why This Matters: Efficiency: Choose the right method for the right task to optimize your APIs.
Performance: Avoid over-fetching or unnecessary operations by using methods purposefully.
Security: Understand which methods expose vulnerabilities (e.g., over-permissive TRACE) and implement safeguards.
Pro Tip: Pair these methods with proper status codes (like 200 OK, 404 Not Found, etc.) and authentication for a robust API design. Activate to view larger image,