How to check API Request Limit using Apex in Salesforce?

How to check API Request Limit using Apex in Salesforce?

Using OrgLimit Class, we can check API Request Limit using Apex in Salesforce.

DailyApiRequests in OrgLimit class holds the Salesforce 24 hours API Usage.

Sample Code: to check Daily Usage

Map < String, System.OrgLimit > limitsMap = OrgLimits.getMap();  
System.OrgLimit apiRequestsLimit = limitsMap.get( 
    'DailyApiRequests' 
);  
System.debug( 
    'Limit Name: ' + 
    apiRequestsLimit.getName() 
);  
System.debug( 
    'Usage Value: ' + 
    apiRequestsLimit.getValue() 
);  
System.debug( 
    'Maximum Limit: ' + 
    apiRequestsLimit.getLimit() 
);  

Output:

Leave a Reply