Ankita
Salesforce Data API
Salesforce provides four main types of APIs for interacting with Salesforce data: REST API,
SOAP API, Bulk API, and Streaming API. Among these, the most commonly used APIs
are generally the REST API and the Bulk API. However, each API is designed for different
use cases, and their popularity depends on the specific needs of the project.
Here's a breakdown of each API and its most common use case:
1. REST API
• Use Case: The Salesforce REST API is the most widely used API for general-
purpose data interactions. It’s ideal for lightweight integrations where you need to
interact with Salesforce records (CRUD operations) or run simple SOQL queries.
• Why It’s Popular:
o Simple and lightweight.
o Best suited for mobile apps, web apps, and external services that need to
integrate with Salesforce.
o Uses standard HTTP methods (GET, POST, PATCH, DELETE), making it
easy to integrate.
o Returns responses in JSON, which is commonly used in modern applications.
• Common Operations:
o Retrieve, create, update, and delete Salesforce records.
o Run SOQL queries to fetch data.
o Access metadata (e.g., objects, fields).
Example Use Case: A mobile app that needs to show user data stored in Salesforce or a web
app that integrates with Salesforce data using REST endpoints.
Example Endpoint:
• GET /services/data/vXX.0/sobjects/Account/ – Retrieve all accounts.
• POST /services/data/vXX.0/sobjects/Account/ – Create a new account.
2. Bulk API
• Use Case: The Salesforce Bulk API is designed for handling large volumes of data.
It’s typically used when you need to perform mass insert, update, delete, or upsert
operations efficiently. This is ideal for batch processing.
• Why It’s Popular:
o Optimized for large datasets (up to millions of records).
Joyful Learning
Ankita
o Allows asynchronous operations, so it doesn’t affect the performance of your
Salesforce instance.
o Can be used to upload or modify large amounts of data without timing out.
• Common Operations:
o Bulk Insert: Inserting a large number of records at once.
o Bulk Update: Updating a large number of records.
o Bulk Delete: Deleting a large number of records.
o Asynchronous operation for better performance.
Example Use Case: A data migration process where you need to upload thousands or
millions of records into Salesforce (e.g., migrating customer records from a legacy system).
Example Endpoint:
• POST /services/data/vXX.0/jobs/ingest/ – Create a job to upload data.
• GET /services/data/vXX.0/jobs/ingest/<job_id> – Check the status of the bulk job.
3. SOAP API
• Use Case: The Salesforce SOAP API is primarily used for legacy systems that
require more complex integrations, particularly when you need a detailed response or
access to the full set of Salesforce features.
• Why It’s Less Common Today:
o Requires more setup compared to the REST API.
o SOAP XML-based responses can be more cumbersome to work with than
JSON.
• Common Operations:
o CRUD operations on records.
o Execute SOQL queries.
o Use complex operations like calling triggers, workflows, and accessing
metadata.
Example Use Case: Legacy systems or enterprise applications that rely on SOAP-based
communication, or integrations where more control over the API’s operations is needed.
Example Endpoint:
• https://login.salesforce.com/services/Soap/u/XX.0 – Used to initiate a SOAP request.
Joyful Learning
Ankita
4. Streaming API
• Use Case: The Salesforce Streaming API is used for real-time notifications and data
streaming. It is ideal for scenarios where you need to listen for changes in Salesforce
data, like updates to records, and react to these changes as they happen.
• Why It’s Popular:
o Best suited for event-driven architecture or systems that need to react to
changes in Salesforce in near real-time.
o Supports the PushTopic and Platform Event models to listen for changes.
• Common Operations:
o Listen to events like record changes or custom platform events.
o Push notifications to external systems whenever specific conditions are met.
Example Use Case: A dashboard that shows real-time updates on opportunities or cases in
Salesforce, or a service that reacts to changes in Salesforce records, like sending email alerts
when certain conditions are met.
Example Endpoint:
• POST /services/data/vXX.0/sobjects/PushTopic/ – Create a PushTopic to listen for
changes.
• Subscribe to a PushTopic using a CometD client to listen for changes.
Which API is Used Most Frequently?
• REST API is the most commonly used API among the four because it offers a
simple, modern, and flexible way to interact with Salesforce data. It is typically used
in web and mobile applications, external systems, and lightweight integrations. Its
simplicity and ease of use make it the default choice for developers.
• Bulk API is the second most popular API for use cases involving large data volumes
or batch data operations, such as data migrations or mass updates.
When to Use Each API:
• Use REST API:
o When building lightweight applications (mobile, web) that need to interact
with Salesforce data.
o For integrations that require simplicity, scalability, and easy setup.
o When working with standard CRUD operations and SOQL queries.
• Use Bulk API:
Joyful Learning
Ankita
o When dealing with large-scale data operations (e.g., migrating or importing
large datasets).
o When performance and asynchronous processing are important, and you’re
working with millions of records.
• Use SOAP API:
o If you are working with legacy systems that need SOAP communication or if
you require detailed or complex operations.
o When you need full access to Salesforce features, including triggers,
workflows, and metadata.
• Use Streaming API:
o When your application needs to react in real-time to changes in Salesforce
data (e.g., a dashboard or service that responds to record changes).
o When building event-driven applications or systems that require real-time
notifications.
Conclusion:
• REST API is used most frequently due to its simplicity and versatility.
• Bulk API is popular for handling large datasets.
• SOAP API is generally used by legacy systems or for more complex integrations.
• Streaming API is favored in applications that need real-time data processing and
event-based reactions.
In most modern applications, REST API and Bulk API are the most commonly used, with
Streaming API being important in event-driven architectures.
Joyful Learning