GET: Retrieving Resources
You'll learn how GET requests work, when to use them, and how query parameters help you fetch exactly the data you need.
What is a GET Request?
A GET request is the HTTP method you use to retrieve data from a server without modifying anything. Think of it like looking up a book in a library—you're just reading information, not changing it.
When your browser loads a webpage, fetches an image, or displays API data, it's almost always using GET requests behind the scenes.
How GET Works
GET requests retrieve resources using their URL (Uniform Resource Locator). The URL acts as the address:
GET /api/users/42
This asks the server: "Please send me the user with ID 42."
Query Parameters: Filtering and Options
Query parameters let you refine what you're asking for. They appear after a ? in the URL:
GET /api/products?category=shoes&size=10&sort=price
Here you're saying: "Give me products that are shoes, size 10, sorted by price." The server processes these filters and returns matching results.
Multiple parameters are separated by &. Common uses include:
- Filtering results (
?status=active) - Pagination (
?page=2&limit=20) - Sorting (
?sort=name) - Searching (
?q=javascript)
When to Use GET
Use GET when you want to:
- Retrieve data without changing server state
- Create bookmarkable or shareable URLs
- Enable browser caching for performance
Don't use GET for:
- Sending sensitive data (credentials appear in URLs)
- Large data payloads (URL length limits)
- Actions that modify resources (use POST, PUT, DELETE instead)
Key Takeaway: GET requests safely retrieve resources using URLs and query parameters—they're read-only operations that don't change server data, making them perfect for fetching, filtering, and displaying information.