'API naming convention when fetching single resource list from collection resource
Let's think that we need endpoint which returns address of users. User ids 1,2,3 and we want to get those users' address. So, when designing api, how should be our route? Normally, when we want to get single user's address we should use:
Get Request -> https://example.com/users/1/address
So, what about with multiple users' address scenario? Scenarios comes to my mind are:
1.Get Request -> https://example.com/users/1,2,3/address (Actually i think that this is not proper way)
2.Get Request -> https://example.com/users/address?user-id=1,2,3
3.Get Request -> https://example.com/users/address?user-id=1&user-id=2&user-id=3
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
