When to Use Tooling API
Use Tooling API when you need fine-grained access to an org’s metadata. Tooling API’s
SOQL capabilities for many metadata types allow you to retrieve smaller pieces of metadata.
Smaller retrieves improve performance, which makes Tooling API a better fit for developing
interactive applications.
Because Tooling API allows you to change just one element within a complex type, it can be easier to use than Metadata API. Other use cases include:
- Source control integration
- Continuous integration
- Apex classes or trigger deployment
Some of the specific tasks you can accomplish using the Tooling API:
- Retrieve metadata about an object’s field: Use FieldDefinition.
- Retrieve custom or standard object properties: Use EntityDefinition.
- Manage working copies of Apex classes and triggers and Visualforce pages and components.: Use ApexClassMember, ApexTriggerMember, ApexPageMember, ApexComponentMember, and MetadataContainer .
- Manage working copies of static resource files.: Use StaticResource.
- Check for updates and errors in working copies of Apex classes and triggers and Visualforce pages and components.: ContainerAsyncRequest
- Commit changes to your organization.: Use ContainerAsyncRequest.
- Set heap dump markers.: Use ApexExecutionOverlayAction
- Overlay Apex code or SOQL statements on an Apex execution.: Use ApexExecutionOverlayAction.
- Execute anonymous Apex.: For sample code, see SOAP Calls and REST Overview.
- Generate log files for yourself or for other users.: Set checkpoints with TraceFlag
- Access debug log and heap dump files.: Use ApexLog and ApexExecutionOverlayResult.
- Manage custom fields on custom objects.: Use CustomField.
- Access code coverage results.: Use ApexCodeCoverage, ApexOrgWideCoverage, and ApexCodeCoverageAggregate.
- Execute tests, and manage test results.: Use ApexTestQueueItem and ApexTestResult.
- Manage validation rules and workflow rules.: Use ValidationRule and WorkflowRule.