Over-Fetching and Under-Fetching Problems in REST
You'll learn how REST's fixed endpoint responses often force clients to receive too much or too little data for their actual needs.
The Problem with Fixed Data Structures
In REST APIs, each endpoint returns a predetermined set of fields. When you request /api/users/123, you might get back:
{
"id": 123,
"name": "Alice",
"email": "alice@example.com",
"bio": "Long biography text...",
"followers": [...],
"posts": [...]
}
Over-fetching happens when your client only needs the user's name, but receives the entire user object—including the bio, followers list, and posts you don't need. You've downloaded extra data, wasting bandwidth and processing time.
Under-fetching occurs when one endpoint doesn't give you enough. If you need user info plus their recent comments, you might need:
GET /api/users/123GET /api/users/123/comments
Now you're making multiple round trips to assemble the data you need.
The Restaurant Analogy
Think of REST endpoints like fixed combo meals. You might only want fries (over-fetching the burger and drink), or you want fries, a burger, and a dessert—but the combo only includes fries and a burger (under-fetching). You're stuck ordering a second item separately.
Why REST Struggles Here
REST's resource-centric model defines endpoints around server resources, not client needs. Each endpoint returns what the server thinks is a "complete" representation. Mobile apps, web dashboards, and smartwatches all hit the same endpoint but need different data shapes.
Key Takeaway: REST endpoints return fixed data structures that often include too much data (over-fetching) or too little (under-fetching), forcing clients to either waste bandwidth or make multiple requests.