Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

Does anyone know how to retrieve the SFDC daily requests API limit through SOAP or REST? I don't see any call for this. Currently, I have to access this info at the Company Info page. I would like to retrieve this info at the code level for batch processing.


1 Answer

0 votes
by (32.1k points)

Try the following code to retrieve the SFDC daily requests API limits through SOAP or REST:

WebService static string GetAPIUsage() {

    PageReference pr = new PageReference('/00D20000000HsCQ');//use id of setup page


    String result = pr.getContent().toString();

    Integer start_index = result.indexOf('API Requests, Last 24 Hours', 1) + 52;

    Integer end_index = result.indexOf('<', start_index);

    result = result.substring(start_index, end_index);

    result = result.replaceAll('&nbsp;', ' ');

    return result;     


Browse Categories