+ Start a Discussion
Cuong Pham 3Cuong Pham 3 

Apex Rest for public do not count against the organization's API?

Hi all,

I create an apex rest for public as below:
example code

And my url call it is: https://ttv-crm-developer-edition.ap2.force.com/services/apexrest/Vn_OlO/listAccounts
When i call it, the API Request number do not count against the organization's API governor limits.
I did it on developer org and sanbox org.
Who could help me explain the reason?
 
Vasani ParthVasani Parth

I  built a similar service some time ago, and made some similar verifications and tests, I can provide some answers as follows:

Any request for 'Your Domain" will count as a page view, see docs (https://help.salesforce.com/apex/HTViewHelpDoc?id=limits_sites.htm&language=en_US)

You can test the service from runscope (https://www.runscope.com/) (or similar), to get real request times. For example, I have a similar service that performs a SOQL & DML to a single contact record (on a dev org), the round trip averages at 630ms.

Yes, this is still an API call and so the limit will apply. You will need to asses the likely hood of hitting this limit based on your knowledge of the service, frequency of calls to it and the average response time tests from runscope. If your service responds instantly there is much less chance of hitting this limit than if your service completes some complex apex perhaps including SOQL and DML before responding seconds later. (see dev blog article (https://developer.salesforce.com/blogs/engineering/2013/05/force-com-concurrent-request-limits.html))

Yes, each call to this public site RestResource will consume 1 API request. I have tested this.
The docs here (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_intro.htm) clearly state the 3mb request/response limit does apply, although this does not explain your tests. However perhaps an exception is made around attachments as these clearly do transport successfully via API (e.g. with force.com dataloader over soap or dataloader.io over soap & rest and many other integration tools).

Please mark this as the best answer if this helps