Friday, July 31, 2015

[Salesforce / REST APIs] API Request limit on REST header response

Plyaing with Salesforce APIs for a super secret project I came across at this (the red one) response header:

    date : "Fri, 31 Jul 2015 22:20:47 GMT",
    set-cookie : -[
       "BrowserId=8gV_vxxxT--xxxi0bg0vug;Path=/;;Expires=Tue, 29-Sep-2015 22:20:47 GMT",
    expires : "Thu, 01 Jan 1970 00:00:00 GMT",
    sforce-limit-info : "api-usage=113/5000000",
    last-modified : "Fri, 24 Jul 2015 12:07:09 GMT",
    content-type : "application/json;charset=UTF-8",
    transfer-encoding : "chunked",

This is basically the number of API requests done since this last call, and it can be used to train external systems not to fail when exceeding this limit.

I'm sure this has been there since the beginning of times and it may be documented and, as a Salesforce expert, I should know it, but it is worth an article!

Only thing to know is that the limit is not precise, this is recalculated asynchronously and thus the number may be not the exact current amount.

To test this try my own REST request utility and try to call a simple global describe:
     GET https://[your_instance]
     Authorization: Bearer [a_valid_session_id]