[SalesForce] Track number of API calls for an application

I'm working on an application, which uses SOAP, REST and Bulk API to integrate with Salesforce.

Is there any API call in Salesforce which enables me to track how much API calls did I consume in a certain time frame?

I'm aware of 'API Calls Made Within Last 7 Days' report, however, I can't find any information on the application which made the calls. It gives me only the number of API calls made using a user's token.

Thanks in advance!

Best Answer

Every time you call a web method in the Partner API the response includes the Limit Info Header in the response.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header>
      <LimitInfoHeader>
         <limitInfo>
            <current>43</current>
            <limit>15000</limit>
            <type>API REQUESTS</type>
         </limitInfo>
      </LimitInfoHeader>
   </soapenv:Header>
   <soapenv:Body>
   <!-- ... -->
   </soapenv:Body>
</soapenv:Envelope>

The header is also available in the REST API - Limit Info Header

Sforce-Limit-Info: api-usage=25/5000;

With this you can monitor your API usage.


Merged from comment for completeness:

I'm interested in knowing how much API calls did my application consume. – Haris Osmanagić

This header is the global account across all applications. The documentation does mention a API REQUESTS PER APP pilot that will provide limit quota information for a connected app. You could try and get on this pilot. Otherwise it is usually best if the application tracks its own usage.

Related Topic