Salesforce APIs – When to use what?

You might be wondering how many different api Salesforce platform supports and when to use what?

Salesforce supports 10 APIs at present and each and everyone of them has the different use case.

 

1. SOAP API

Use SOAP API to create, retrieve, update or delete records, such as accounts, leads, and custom objects. With more than 20 different calls, SOAP API also allows you to maintain passwords, perform searches, and much more. Use SOAP API in any language that supports Web services.

SOAP API uses the synchronous framework and uses XML based request and response. It does not support JSON. Using XML format make SOAP API heavier than other API that uses JSON format but at the same time, it provides the high level of security as well.

Use SOAP API if you want to make the synchronous transaction to salesforce with more secured request and response.

2. 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.

REST API uses the synchronous framework and supports both JSON and XML based request and response. Its mostly used with JSON request type.

Use REST API if you want to make lightweight synchronous transaction to salesforce. Also, it is the best choice for making transaction in mobile devices.

3. 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, queryAll, 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. You can use SOAP API 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.

BULK API uses the asynchronous framework and supports JSON based request and response. It is more practical when you deal with very large amount of data and do not care much about real time updation.

4. Metadata API

Use Metadata API to retrieve, deploy, create, update, or delete customizations for your org. The most common use is to migrate changes from a sandbox or testing org 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.

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 Ant Migration Tool is ideal if you use a script or the command line for moving metadata between a local directory and a Salesforce org.

The easiest way to access the functionality in Metadata API is to use the Force.com IDE or Ant 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.

5. Tooling API

Use Tooling API to build custom development tools or apps for Salesforce Platform applications. 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.Tooling API provides SOAP and REST interfaces.

For example, you can:

  • Add features and functionality to your existing Salesforce Platform tools.
  • Build dynamic modules for Salesforce Platform development into your enterprise integration tools.
  • Build specialized development tools for a specific application or service.

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.

6. Streaming API

Streaming API is useful when you want notifications to be pushed from the server to the client based on criteria that you define. Consider the following applications for Streaming API:

Applications that poll frequently
Applications that have constant polling action against the Salesforce infrastructure, consuming unnecessary API calls and processing time, would benefit from Streaming API which reduces the number of requests that return no data.
General notification
Use Streaming API for applications that require general notification of data changes in an organization. This enables you to reduce the number of API calls and improve performance.

The sequence of events when using Streaming API is as follows:

  1. Create a PushTopic based on a SOQL query. This defines the channel.
  2. Clients subscribe to the channel.
  3. A record is created, updated, deleted, or undeleted (an event occurs). The changes to that record are evaluated.
  4. If the record changes match the criteria of the PushTopic query, a notification is generated by the server and received by the subscribed clients.

7. APEX REST API

The Force.com REST API lets you use a simple and lightweight API to access Force.com data, using standard OAuth, together with a choice of data flavors – XML and JSON. The REST API is configured out of the box to suit the basic CRUD (create, read, update and delete) operations of data management.

Apex REST augments this functionality and makes it possible for developers to create your own REST-based web services using Apex. It has all of the advantages of the REST architecture, provides the ability to define custom logic and includes automatic argument/object mapping.

8. Apex SOAP API

You can expose your Apex methods as SOAP web services so that external applications can access your code and your application.

9. Chatter REST API

Use Chatter REST API to display Salesforce data, especially in mobile applications. In addition to Chatter feeds, users, groups, and followers, Chatter REST API provides 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 beyond Chatter.

 Many Chatter REST API resource actions are exposed as static methods on Apex classes in the ConnectApi namespace. These classes are called Chatter in Apex. Use Chatter in Apex to create custom experiences in Salesforce. Chatter in Apex is available in all organizations and editions that have Apex enabled.

10. Data.com API

Data.com provides 100% complete, high quality data, updated in real-time in the cloud, and with comprehensive coverage worldwide. The Data.com API leverages Salesforce Data.com Prospector and Data.com Clean to provide accurate account and contact information from Data.com. The Data.com API searches and matches company and contact records. Data.com “company” records are similar to Salesforce “account” records.

 

Most of this article’s content I have picked up from official Salesforce documentation, but the intent here is to give you an overview of each API at one single place and also to give an Idea of what to use when. Please read official documentation to get deep idea about each API.

 

Please do share your feedback and suggestions.

Manish Choudhari

I am a certified Salesforce Application & System Architect and Developer working on Salesforce Technology since 2014. Currently, I have 14 Salesforce certifications along with OCPJP (Oracle Certified Profession JavaSE6 Programmer) working in Salesforce.com Hyderabad as a Technical Engineer. Writing technical blogs, learning new technologies and frameworks and sharing knowledge is my hobby.

This Post Has One Comment

  1. Avatar

    Great work, thanks for sharing useful resource in simplified manner.

    Friends to be noted, there is one more API Bulk API 2.0.
    #reference: https://developer.salesforce.com/docs/atlas.en-us.api_bulk_v2.meta/api_bulk_v2/introduction_bulk_api_2.htm

    Salesforce provides an additional API, Bulk API 2.0, which uses the REST API framework to provide similar capabilities to Bulk API. Use Bulk API 2.0 instead of Bulk API if you want a simplified process for inserting, updating, upserting, or deleting large sets of data. Bulk API 2.0 does not currently support query or queryAll.

Leave a Reply

Close Menu