0

Say we have a grpc microservice which have endpoint GetDataById(int id). If I came across a use case where I want data of multiple ids, should I create separate endpoint like GetDataByIds(int[] ids) or should I call GetDataById(int id) multiple time in parallel.

Rakesh
  • 71
  • 1
  • 6
  • 1
    It really depends on your usecase. To me it seems that `GetDataById` is a subset of `GetDataByIds`, so I would personally only implement the latter and call it with a single value if needed. Calling multiple requests in parallel doesn't seem wise, as it would generate unnecessary traffic overhead and wouldn't be faster anyway. – Papooch May 05 '20 at 13:02
  • My suggestion is to build only one API. Does https://stackoverflow.com/questions/9371195/rest-api-requesting-multiple-resources-in-a-single-get/9372278 answer your question? – Jitesh Shivnani May 05 '20 at 19:54
  • @JiteshShivnani I think they are a little bit different. In my case, we are using grpcs microservice which is used to communicate between server to server and I already have endpoint GetDataById(int id). I just wanted to understand if I should make diff calls in parallel or should create another endpoint with multiple ids as input. – Rakesh May 06 '20 at 11:47
  • only make GetDataByIds(int[] ids) – Jitesh Shivnani May 06 '20 at 12:08

0 Answers0