0

I am consuming web-service in my spring boot application.I need to fetch information from apis. This information can be fetched by calling different nested apis:

  1. getAllColleges - gives ids of all colleges
  2. /college/{id}/departments - gives id of departments of a college
  3. /college/{id}/department/{dId} - Gives details of a department which includes staff information

As of now i understand that first i have to fetch all colleges using first api and iterate over them.In each iteration i will have to call again next api and get a bunch of departments and there will be a nested iteration on departments and then i'll get staff information using another api.

Is there any better approach so that so much iteration (and obviously calling apis in each iteration) can be avoided.

James Z
  • 12,209
  • 10
  • 24
  • 44
Manish
  • 1,274
  • 3
  • 22
  • 59
  • This is not good approach.. as long as you college increase then API hit will increase tremendously. So correct your database design with all college and department. You can achieve this with couple of database hit. – GnanaJeyam Sep 16 '19 at 18:23
  • @gnanajeyam95 i understand that but it's a bunch of apis provided by third-party.I have no control over it. Is there anything that i can do to handle it on my side. – Manish Sep 17 '19 at 04:36
  • Then create a new scheduler job and fetch all relevant data and put it in your database and get the data from your database. – GnanaJeyam Sep 17 '19 at 04:53
  • Yes, that's what i am doing right now. – Manish Sep 17 '19 at 08:36

0 Answers0