[SalesForce] How to List all Custom Objects from Salesforce API

I'm currently working to use the Salesforce REST API to get a list of all Salesforce Custom SObjects without including System or Standard Objects (like how the /services/data/vXX.X/sobjects/ does).

Is this possible or supported? I have found this answer which suggests using the following query:

SELECT SObjectType From ObjectPermissions Group By SObjectType

to get any object where you can assign a permission, but I do not know if that is a reasonable alternative to a simple Custom Objects call that I am seeking.

Ideally I would like both the name and label properties in the list, as I can query based on the object name for specifics later.

For Additional Context:
The goal is to have a user select from a typeahead which object they would like to load. I originally was using the Describe route, however fetching the 2.3k objects (2.2MB payload) and filtering out non-custom objects take between 2 to 3 seconds, which is not effective.

Thank you in advance for any pointers.

Best Answer

No. The closest you can get is the Tooling API query "SELECT DeveloperName FROM CustomObject", which does (mostly) what you want, except that (a) you can't get the label, and (b) you need View All Data in order to use this API. In addition, your query would be limited to 2,000 custom objects, so this may not work in all orgs (I believe the limit in some orgs is 9,999 objects). In your case, I would prefetch the data, then filter client-side. You'll have a couple of seconds loading time, but only once per load (less if you use a @wire to cache the data).

Related Topic