Reputation: 1044
I'm designing a RESTful API and I have a pretty simple "philosophical" question:
I have a resource representing a set of values stored in a period of time:
loggers/2/data?begin=10h&end=12h
Doing this request I get the data stored by a Data Logger (with id=2) from 10:00h to 12:00h.
response:
[
{
"data": "10h",
"value": 10
},
{
"data": "11h",
"value": 15
},
{
"data": "12h",
"value": 9
}
]
Now, I want only the max value in this period:
[
{
"data": "11h",
"value": 15
}
]
So... Is this a new resource? like:
loggers/2/data/max?begin=10h&end=12h
or the same resource filtered?
loggers/2/data?begin=10h&end=12h&filter=max
What do you think? thanks!
Upvotes: 1
Views: 74
Reputation: 1109
I suggest a new resource as it's kind-of corresponding to a new method for the given entity.
In my WebApp I use the following format:
/entity/method/id
eg /user/retrieve/5
or /user/settings/5
/entity/method
eg /user/create
or /user/oldest
/user
(I might have decided to do /user/all
Upvotes: 3