Reputation: 356
Lets say I am designing a Restful service which given 2 integer no.'s returns the sum of it. In this case there is no resource to be read, created, updated or deleted. So, if I design something like GET /sum/first/33/second/44, it doesn't comply with the REST standards as 'sum' is a verb and instead there should be a noun representing the resource name. So, how should the API call look like for invoking the sum.
Please help me with the design.
Upvotes: 2
Views: 207
Reputation: 10991
REST says nothing about what your URLs should look like. You can honestly have anything you want: GET /hdueqixp
returning "77", for example.
Me, I like short, self-explanitory URIs. I would use /sum/33+44
. You're not including action parameters in the request URL, so don't worry about verbs vs. nouns. That is for people still doing things like GET /users/deepak?action=delete
and expecing the resource to be deleted.
Upvotes: 1
Reputation: 38645
Use "summation" instead of "sum" if your concern is noun vs. verb. As far as parameters are concerned, I think you should supply all the numbers you want to sum up together for eg. /summation/1,2,3,4 or /summation/1+2+3+4.
Upvotes: 5