HTTP GET Method: Complete Guide with Examples
The HTTP GET method is the most commonly used request method on the internet. Every time you load a webpage, search on Google, click a product on Amazon, or refresh a feed — your browser is making a GET request.
This method is used only to retrieve information, never to modify it.
What is the GET Method?
The GET method asks the server to return data or a resource. It is:
- Safe → does not modify data
- Idempotent → multiple identical GET requests give the same result
- Cacheable → can be stored by browsers/CDNs for faster loading
- No request body → parameters go in the URL
Basic GET Request Example
GET /api/users/5 HTTP/1.1
Host: example.com
Accept: application/json
Response (200 OK)
{
"id": 5,
"name": "Aarav Mehta",
"email": "aarav@example.com"
}
This request simply retrieves user details and does not modify anything.
GET Request With Query Parameters
Query parameters add filters or search options.
Example: Get products by category
GET /api/products?category=mobiles&sort=low-to-high
This tells the server to:
- Fetch products in “mobiles”
- Sort them by price (low → high)
Response Example
[
{
"id": 101,
"name": "Samsung Galaxy A55",
"price": 22999
},
{
"id": 102,
"name": "Realme 13 Pro",
"price": 24999
}
]
GET Request With Headers
Sometimes you send additional data via headers:
GET /api/account HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Accept-Language: en-IN
Cache-Control: no-cache
Headers help with:
- Authentication
- Localization
- Caching rules
- Content negotiation
GET Request in the Browser (URL Example)
If you type this in a browser:
https://example.com/blogs?page=2&limit=10
The browser sends:
GET /blogs?page=2&limit=10 HTTP/1.1
Real-World Use Cases of GET Method
✔ 1. Fetching webpage content
Every webpage load is a GET request.
GET /index.html
✔ 2. Fetching API data
Used in web apps, mobile apps, dashboards.
GET /api/todos
✔ 3. Search functionality
GET /search?query=laptops
✔ 4. Pagination
GET /news?page=5
✔ 5. Downloading files (metadata check)
GET /downloads/app.apk
Security Considerations for GET Method
❌ Never use GET for sensitive information
Example (bad):
GET /login?username=admin&password=12345
Passwords become visible in:
- Browser history
- Server logs
- Network logs
- Bookmarks
Always use POST for sensitive actions.
GET vs POST: Key Differences
| Feature | GET | POST |
|---|---|---|
| Purpose | Retrieve data | Send/modify data |
| Body allowed | ❌ No | ✔ Yes |
| URL length | Limited | Unlimited |
| Visibility | Visible in URL | Hidden in body |
| Safe | ✔ Yes | ❌ No |
| Idempotent | ✔ Yes | ❌ No |
Caching with GET
Browsers and CDNs often cache GET responses.
Request:
GET /images/logo.png
Server Response:
Cache-Control: max-age=86400
This improves performance and reduces server load.
When NOT to Use GET
Do NOT use GET for:
- Login operations
- Updating data
- Deleting data
- Uploading files
- Sensitive info (passwords, OTP, tokens)
Use POST, PUT, PATCH, DELETE for such operations.
Conclusion
The GET method is the backbone of web communication.
It is safe, fast, cacheable, and ideal for retrieving data without making changes on the server.
Mastering GET is essential for:
- API developers
- Frontend programmers
- Mobile app developers
- Testers
- Anyone building modern web apps
