Reputation: 1596
I have a resource "User" for which we store following details:
{
"id": 123,
"name": "John Doe",
"address": {
"line1": "411, ABC street"
"city": "XYZ"
"country": "ZZZ"
}
}
I need three APIs to list my User resource:
What URI pattern should I use for each of the above?
Upvotes: 2
Views: 471
Reputation:
Since all three requests are for the same resource, all three should use the same URL. For example:
/users
If the client requests a different representation, it should use the proper HTTP header Accept
. You should define vendor types that identify the different representations. For example:
To get the represenation including only the IDs:
GET /users
Accept: application/vnd.acme.users.ids+json
To get the represenation including IDs and names:
GET /users
Accept: application/vnd.acme.users.idsandnames+json
To get the represenation including everything:
GET /users
Accept: application/vnd.acme.users+json
Upvotes: 2