Best Practice...Call API with loop.

71 views
Skip to first unread message

Thomas Lombard

unread,
Oct 27, 2019, 5:22:16 PM10/27/19
to Guzzle - PHP HTTP client and REST client framework

QUESTION TO THE FORUM, what is best practice to call GET API many-many times within a loop?

I have ~1,000 employees. I need to loop through each of them...no problem there.

Within my loop, for each employee, I need to reach out to a 3rd party server via an API, GET a few of the data elements sent back to me...and store those elements to mySQL

I have it running using PHP and calling cURL each loop interaction...BUT IT IS VERY_VERY_VERY SLOW.


foreach (employee) {

 STEP #1 GET from API URL: http://www.apidomain.com/users?employeeID=.employeeID

 STEP #2 based upon response from the GET API, store the data retuned from the API to mySQL

}

Thanks for advice!!!, Tom


Reply all
Reply to author
Forward
0 new messages