API Design · Junior · Question 74 of 75
How can a client fetch several users by ID in one request in a REST API?
- 1By sending three GET requests in one HTTP body
- 2It's impossible in REST
- ✓Correct answer: With a filter on the collection, e.g.
GET /users?ids=1,2,3, within a documented maximum
Explanation
Batch reads reduce round trips. Large ID lists may need POST /users:batchGet with a body because URLs have length limits.