Ora

How many HTTP methods are there?

Published in HTTP Methods 4 mins read

There are 39 official HTTP methods listed in the HTTP Request Method registry. These methods, also known as HTTP verbs, define the type of action a client wants to perform on a web server's resource.

The Official Count of HTTP Methods

While many developers frequently use a limited set of HTTP methods like GET, PUT, or POST, the official registry maintained by the Internet Assigned Numbers Authority (IANA) encompasses a total of 39 distinct HTTP verbs. Each method is designed to provide a specific interaction model, allowing for powerful and precise operations on web resources.

Common HTTP Methods Explained

Despite the extensive list, a handful of methods are widely adopted for building web APIs and applications. Understanding these common verbs is crucial for effective web development.

Here are some of the most frequently used HTTP methods, including the core ones developers typically work with:

Method Description Idempotent? Safe?
GET Retrieves data from the server. Yes Yes
POST Submits data to the server, often creating a new resource. No No
PUT Updates an existing resource or creates one if it doesn't exist at a specific URI. Yes No
DELETE Removes a specified resource from the server. Yes No
PATCH Applies partial modifications to a resource. No No
HEAD Requests only the headers of a resource, without the body. Yes Yes
OPTIONS Retrieves the communication options available for the target resource. Yes Yes
CONNECT Establishes a tunnel to the server identified by the target resource. No No
TRACE Performs a message loop-back test along the path to the target resource. Yes Yes

Understanding Key HTTP Verbs

Each HTTP method plays a distinct role in how clients and servers interact:

  • GET: The most common method, used to retrieve data from a specified resource without altering the server's state. For example, loading a webpage or fetching a list of products.
  • POST: Used to send data to the server to create a new resource or perform an operation that doesn't fit other HTTP methods. Submitting a form or uploading a file are common use cases.
  • PUT: Primarily used to update an existing resource with new data. If the resource identified by the URI doesn't exist, PUT can also create it. It replaces the entire resource.
  • DELETE: Instructs the server to remove the resource identified by the URI.
  • PATCH: Used for applying partial modifications to a resource. Unlike PUT, PATCH only sends the changes needed, rather than the entire updated resource.
  • HEAD: Identical to GET, but it only requests the HTTP headers of the resource, not the body. This is useful for checking a resource's metadata (like content type or last modified date) without downloading its full content.
  • OPTIONS: Allows a client to discover the communication options or capabilities supported by a web server for a particular resource. It's often used for cross-origin resource sharing (CORS) preflight requests.
  • CONNECT: Establishes a two-way communication tunnel to the target resource, typically used by a client to connect to a web server through an HTTP proxy.
  • TRACE: A diagnostic method that performs a message loop-back test. The server reflects the received request back to the client, allowing the client to see what (if any) changes or additions have been made by intermediate servers.

Why So Many HTTP Methods?

The existence of numerous HTTP methods ensures that the protocol is highly expressive and extensible. While many are specialized for particular use cases (such as WebDAV methods like PROPFIND or MKCOL), they collectively enable a rich set of interactions between clients and servers. This extensibility allows HTTP to support a wide range of applications beyond simple web browsing, from complex API integrations to distributed authoring and versioning.