function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Do @RestResource calls count to API usage limit?


I have provided a REST public service toward an Apex Class with @RestResource annotation.
This service can be called by everyone and I wish to know if it counts to API Usage limit or not. Actually I see that the number of REST call increase the count in API Report but not in System Overview Api Usage.

As you can see I have 143 call from Community guest user and 140 calls fro a Salesforce user

User-added image

But in Salesforce Overview I see only calls done by a Salesforce user:

User-added image

What does it mean? Public calls don't count? Or it' s just a Salesforce bug on system overview console?

NehalNehal (Salesforce Developers) 


@RestResource annotated apex classes are just like normal apex class and only difference is that they expose the apex class as a HTTP GET,POST,PUT or PATCH web-service and hence all the governor limits applicable to the apex class context apply here .

These limits will be 50,000 queries in a context,150 DML,100 SOQL limit of context ,CPU limit ,Heap size limit etc ,all this generally applies .

In terms of number of API calls ,each request will count against number of API calls and no of API calls allowed for your org depends on edition and as well as license .Also these API calls can be purchased from sfdc with some additional cost(Contact SFDC for same )

Before jumping into writing your custom apex rest service I would strongly recommend to use the standard REST API provided by sfdc ,if any of the API provided by sfdc meets the requirement I would use that as they are faster and have capability to automatically return data in chunks

The above document link has a reference and you will find explanation for standard REST services available out of box.If any of them don't fit then you will need to build apex REST service and an optimized code is necessary to avoid governor limits .

Also refer to below article:

I hope this helps. Please mark this as a ""Best Answer"" if this has resolved your issue.