function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GAURAV SETHGAURAV SETH 

How to make more than 100 API Calls

Hi Everyone, I have a requirement where we need to make more than 100 API calls in real time. As we all know that will hit governor limits.
We can't use Batch to call the API's . What is the best way to handle such situation ?
PriyaPriya (Salesforce Developers) 
Hey Gaurav,

Kindly refer this link which exactly matches your requirement :- 
https://salesforce.stackexchange.com/questions/196916/more-than-100-api-calls-and-insertion-of-more-than-1000-records

Also, if needed, to increase the limit of API request, you can refer this document :- 
https://help.salesforce.com/s/articleView?id=000315571&type=1 (https://help.salesforce.com/s/articleView?id=000315571&type=1)

Kindly mark it as the best answer if it helps you.

Thank you,
Priya Ranjan
GAURAV SETHGAURAV SETH
Thanks for your response but do not solve my issue. I have a situation where I have 3 levels. 
Level 1 have only 1 API Call-This is fine
Level 2 can have more than 100 API calls for each item
Level 3 can have more than 100 API calls for each item
 
Bryan Leaman 6Bryan Leaman 6
If you believe you can't use Batch to call the API's, maybe you need an architectural change to your solution?
Since you mention making the calls in "real time" I'm assuming you have some sort of screen interaction that launches these calls. If so, you should be able to implement one of the following options: 

Option 1: Define all the API calls you need as a discrete list of some sort of SObject with the description of what API call is needed (possibly as uncommitted Task objects, if nothing else works for you), then submit the batch and monitor it for completion in  javascript (with periodic alls to apex to get the batch job status).

Option 2: Offload the api calls themselves to javascript and store the results of each until they all complete, or even fill in your screen as API calls return with additional information.

Option 3: Depending on what determines the suite of API calls you need, you could split them into separate method calls where each method performs < 100 API calls and then string your controller method calls together sequentially from your screen (vf page/lwc component, whatever) so that as each finishes the next one is invoked. Each controller method invocation is a separate request in saleforce and subject to a new set of limits.


 
GAURAV SETHGAURAV SETH
Thanks Bryan for giving all options. 
Option 1 and Option 2 doesn't fit to my requirement as API calls are not directly requested from the screen.
We need to have some calculation in Apex and then need to call those API's based on the result.
Bryan Leaman 6Bryan Leaman 6
Looks like you'll have to go off-platform for level 2 & level 3 and use some other tool to perform all your api calls and return an aggregate result of them all.