HTTP GET is one of the most common methods used in the Hypertext Transfer Protocol (HTTP) for requesting data from a server. When a client, such as a web browser, wants to retrieve information—like a web page, image, or data from an API—it sends a GET request to the server specifying the resource it wants to access.
Key characteristics of HTTP GET:
- Purpose: GET is used strictly to retrieve data from a specified resource. It does not modify any data on the server.
- Request structure: The GET request includes the resource’s URL (Uniform Resource Locator) and may append parameters as a query string (e.g.,
/search?q=example
). These parameters are visible in the URL. - No request body: GET requests do not have a message body; all necessary information is included in the URL and headers.
- Safe and idempotent: GET is considered a safe method (it does not change server state) and idempotent (making the same request multiple times yields the same result).
- Cacheable: Responses to GET requests can be cached by browsers or intermediary servers for efficiency.
- Browser behavior: GET requests can be bookmarked, remain in browser history, and are subject to length restrictions due to URL limits.
- Security: Since data is sent in the URL, GET should not be used for sensitive information, as URLs can be logged or intercepted.
Example GET request:
GET /contact HTTP/1.1
Host: example.com
The server responds with the requested resource, such as an HTML page or data file.