Salesforce provides programmatic access to your organization’s information using simple, powerful, and secure application programming interfaces.
Here in this blog post i will consolidate the details for these APIs from different sources into one place to make it easy understanding the APIs and finding out when to use which API. this might not be all of the details , but i tried my best to put all things together. Please make sure that you use this as a reference and also check other resources before you proceed .At the end i also listed out few tips from my experience to consider when using these APIs.
What each API provides
Following is a quick detail about what each API provides. for more information on how to access and use Salesforce APIs you can go to each link:
- REST API – Access objects in your organization using REST.
- SOAP API – Integrate your organization’s data with other applications using SOAP.
- Tooling API – Build custom development tools for Force.com applications. Coming soon!
- Chatter REST API – Access Chatter feeds and social data such as users, groups, followers, and files using REST.
- Bulk API – Load or delete large numbers of records.
- Metadata API – Manage customizations in your org and build tools that manage the metadata model (not the data, itself).
- Streaming API – Provide a stream of data reflecting data changes in your organization.
- Apex REST API – Build your own REST API in Apex. This API exposes Apex classes as RESTful Web services.
- Apex SOAP API – Create custom SOAP Web services in Apex. This API exposes Apex classes as SOAP Web services.
- Data.com API – Data.com provides 100% complete, high quality data, updated in real-time in the cloud, and with comprehensive coverage worldwide.
When to use each API
Now you know what each API provides and you might be thinking from these wide options which is suitable to my use case and when to use which API. below table gives the protocol , Data format and type of communication for each API. and followed by when to use each API.
When to Use REST API
REST API provides a powerful, convenient, and simple REST-based Web services interface for interacting with Salesforce. Its advantages include ease of integration and development, and it’s an excellent choice of technology for use with mobile applications and Web projects. However, if you have many records to process, consider using Bulk API, which is based on REST principles and optimized for large sets of data.
When to Use SOAP API
SOAP API provides a powerful, convenient, and simple SOAP-based Web services interface for interacting with Salesforce. You can useSOAP API to create, retrieve, update, or delete records. You can also use SOAP API to perform searches and much more. Use SOAP APIin any language that supports Web services.
For example, you can use SOAP API to integrate Salesforce with your organization’s ERP and finance systems. You can also deliver real-time sales and support information to company portals, and populate critical business systems with customer information.
When to Use Chatter REST API
Use Chatter REST API to display Salesforce data, especially in mobile applications. Responses are localized, structured for presentation, and can be filtered to contain only what the app needs. In addition to Chatter feeds, users, groups, and followers, Chatter REST APIprovides programmatic access to files, recommendations, topics, notifications, Data.com purchasing, and more. Chatter REST API is similar to APIs offered by other companies with feeds, such as Facebook and Twitter, but it also exposes Salesforce features beyondChatter.
When to Use Bulk API
Bulk API is based on REST principles and is optimized for loading or deleting large sets of data. You can use it to query, insert, update, upsert, or delete many records asynchronously by submitting batches. Salesforce processes batches in the background.
SOAP API, in contrast, is optimized for real-time client applications that update a few records at a time. SOAP API can be used for processing many records, but when the data sets contain hundreds of thousands of records, SOAP API is less practical. Bulk API is designed to make it simple to process data from a few thousand to millions of records.
The easiest way to use Bulk API is to enable it for processing records in Data Loader using CSV files. Using Data Loader avoids the need to write your own client application.
When to Use Metadata API
Use Metadata API to retrieve, deploy, create, update, or delete customizations for your organization. The most common use is to migrate changes from a sandbox or testing organization to your production environment. Metadata API is intended for managing customizations and for building tools that can manage the metadata model, not the data itself.
The easiest way to access the functionality in Metadata API is to use the Force.com IDE or Force.com Migration Tool. Both tools are built on top of Metadata API and use the standard Eclipse and Ant tools respectively to simplify working with Metadata API.
- Force.com IDE is built on the Eclipse platform, for programmers familiar with integrated development environments. Code, compile, test, and deploy from within the IDE.
- The Force.com Migration Tool is ideal if you use a script or the command line for moving metadata between a local directory and aSalesforce organization.
When to Use Streaming API
Use Streaming API to receive notifications for changes to data that match a SOQL query that you define.
Streaming API is useful when you want notifications to be pushed from the server to the client. Consider Streaming API for applications that poll frequently. Applications that have constant polling against the Salesforce infrastructure consume unnecessary API call and processing time. Streaming API reduces the number of requests that return no data, and is also ideal for applications that require general notification of data changes.
Streaming API enables you to reduce the number of API calls and improve performance.
When to Use Apex REST API
Use Apex REST API when you want to expose your Apex classes and methods so that external applications can access your code through REST architecture. Apex REST API supports both OAuth 2.0 and Session ID for authorization.
When to Use Apex SOAP API
Use Apex SOAP API when you want to expose Apex methods as SOAP Web service APIs so that external applications can access your code through SOAP.
Apex SOAP API supports both OAuth 2.0 and Session ID for authorization.
When to Use Tooling API
Use Tooling API to integrate Salesforce metadata with other systems. Metadata types are exposed as sObjects, so you can access one component of a complex type. This field-level access speeds up operations on complex metadata types. You can also build custom development tools for Force.com applications. For example, use Tooling API to manage and deploy working copies of Apex classes and triggers and Visualforce pages and components. You can also set checkpoints or heap dump markers, execute anonymous Apex, and access logging and code coverage information.
REST and SOAP are both supported.
API Governor Limits
Once you understand what each API provides and when to use which API, the next thing you need to understand is the “Salesforce API governor limits”. It is very important to know what are the limits based on your salesforce edition and validate them against your integration use case that you want to implement. below is the link for API limits from salesforce limits cheatsheet which provides details for all API limits based on your salesforce edition and licenses.
Salesforce API limits
Useful Tips/Points when using Salesforce APIs
- Understand all different APIs provided
- Validate your use case against each API to decide which API will satisfy your requirement.
- Check out if you can make use of any ETL tool (like Informatica, Pentaho, Dell Boomi etc.) or any AppExchange app before you go and implement your own solution from scratch.
- Advantage of using an existing tool is quick roll out of your integration to production and there is no maintenance of the code.
- Advantage of implementing your own solution from scratch is you have more control of what you implement , can customize it your specific needs and need not depend on the tool vendor for any upgrades.
- Whether you use any third party tool or implement your own solution you need to make sure that you consider Salesforce API limits in deciding on the record batch sizes and few other details to make sure you wont hit salesforce limits when the integration runs.
- You need to be more cautious from “batch size” perspective if you have any triggers, Process builder processes , workflows on the objects and make sure you bulkify them.
Above tips are general and can be applied to any use case. make sure that you also consider your specific implementation use case to see if they are any other implications.