i have question similar to this article ( Multiple optional query string parameters REST API GET ) but the given answers have 3 different opinion/answer and i dont know which one is the best practice to use, ive searched everywhere but cant find the definite answer.can someone please help me which answer is the right one and has a prove(trusted source that backing it up) that it is a best practice, sorry for bad english i hope you can understand what im saying,
Asked
Active
Viewed 2,035 times
0
-
could you please include your actual question in the text instead of including just a link? Also see [how-to-ask](https://stackoverflow.com/help/how-to-ask) – ophychius Jan 13 '22 at 05:26
-
its too long article,is it okay if i post stacoverflow link instead? – william william Jan 14 '22 at 01:26
-
Does this answer your question? [Multiple optional query string parameters REST API GET](https://stackoverflow.com/questions/34882340/multiple-optional-query-string-parameters-rest-api-get) – ophychius Jan 17 '22 at 07:47
2 Answers
0
The best way is to add filters in get request. Response in this post gives one example -
Best practice for filtering results from a RESTful API call?
In rest everything is a resource so if you want to filter items within same resource you can pass filter criteria along with pagination parameters. Generally only for separate resources we create a new API for optional parameters or to filter within same resource separate APIs should not be created. They are additional testing and maintenance cost.

Jitesh Shivnani
- 363
- 1
- 9
-1
To me answer #2 in the article makes most sense. You will be ok going with it

dbCoder
- 114
- 5
-
thanks for the response, if i go with answer #2 it means on my code i must hv many method with different/all possbile combination of parameters ( like overloading )? ex : public get (int crewid){} , public get (dateteime shiftdate), public (datetime shiftdate, int crewid) ? – william william Jan 13 '22 at 09:46
-
I would make get methods that use IDs And search methods with multiple parameters Remember that passing multiple parameters means you can get more than one item. Design get to return 1 or 0 items (if id can't be found, it returns error), design search to return 0 to many depending on what it finds. This way it makes most sense semantically. – dbCoder Jan 13 '22 at 11:37