Loading...
New Winner – Cross-Border Excellence | Payoneer India 2026 Check out
Featured Recognized by Salesforce; Proven by impact! Check out

Why Call APIs Without Apex? Traditionally, calling external APIs from Salesforce has required Apex classes, Named Credentials, and careful governor limit management. But with modern web standards and the rise of JavaScript-first development in Lightning Web Components (LWC), you can now perform secure, real-time API callouts directly in JavaScript without a single line of Apex.

Let’s explore how you can do an API callout without using Apex.

What are the advantages of calling the API without Apex?

  • Faster User Experience (UX) / No Server Round Trip
  • Less Apex Governor Limits Stress
  • No Need for Platform Events or Queueables
  • Modern APIs (OAuth, REST, GraphQL) Support
  • No Code Deployments
  • Real-time / Event-based Scenarios
  • JS callouts can easily be used with WebSockets, Server-Sent Events, or Polling.

Here are some advantages of using Apex for callout

  • Security / Compliance (Named Credentials)
  • Governor Limits Awareness
  • Bypasses CORS Limitations
  • Batch / Scheduled Jobs
  • More Complex Orchestration
  • API Response Caching
  • Multi-User / Org-Wide Context

In this blog, we’ll show you how to build a fully functional LWC that fetches recipe data from the Spoonacular API, all without writing a single Apex class.

Step-by-Step Guide: Build a Spoonacular LWC Without Apex

We’ll walk you through everything from setting up Trusted URLs, Custom Labels, and the LWC component to executing the callout using native JavaScript fetch().

Keeping them in mind, let’s start with the API callout session. For this, we are using Spoonacular API to demonstrate the use of the API without Apex.

Spoonacular is a free API that you can also use after you create an account here. Before we create a Lightning component, we have to add the Spoonacular URL in Trusted URL, and get the API key, which we will store in the Custom Labels. For that, we need to followa  few steps.

For Spoonacular URL in Trusted URL:

Step 1: Click on the Gear Icon and click on Setup.

seq1 1

Step 2: Search for CSP and click on Trusted URL.

seq2 1

Step 3: Click on New Trusted URL.

seq3 1

Step 4: Fill in the required Details.

seq4 1

For this example, let’s select all the CSP Directives, but you can do as per your needs.

  1. (Optional) Click on “Save & New” and do the Same for images as well from Spoonacular

-> URL will be “https://img.spoonacular.com”

Now, once the Trusted URL is set up and ready to go, we can get the API Key and paste it into the Custom Labels.

For getting the API key and storing it in Custom Labels:

Step 1: Once you log in to your Spoonacular account, go to “Profile & API Key” section. From there, click on the  “Show / Hide API Key” button and then copy the API key that will be there

seq5 1

Step 2: Now, go back to your Salesforce org and in the setup section, go to Custom Labels and click on “New Custom Label.”

seq6 1

Step 3: Then, fill in Short Description, Name, and Value, and click on the “Save” button.

seq7 2

Once the Trusted URL and Custom Label with API key are set up, we can create a Lightning component and make a callout.

Now, create an LWC component:

Step 1: Open VS Code and create a new component:
sfdx force:lightning:component:create –type lwc -n advanceDataFetcher -d force-app/main/default/lwc

seq8 1

Step 2: Let’s start, i.e., we will start with the JavaScript first as it is the important part here

JavaScript

HTML

CSS

XML

Final Output

Here is the final component main screen we have created

seq9 1

And, when we search for some specific food item, Rice in this example, and click on the “Make Callout” button, then it will fetch the records.

seq10 1

Additionally, I have added a view icon that will show more information about the recipe you have selected, and from there, you can learn more about that recipe.

seq11 1

Watch the quick demo to see how easily LWC + JavaScript = powerful API integrations.

Demo Video:

Conclusion

API callouts using LWC JavaScript unlock a modern, flexible, and developer-friendly approach to integrations inside Salesforce. With proper CORS handling and secure storage of your API keys (via Custom Labels), you can build real-time features faster than ever.

If you’re building lightweight, responsive, or front-end-heavy apps in Salesforce, JavaScript-based API callouts are a game-changer.

No Data Found.

Related Articles
From SMBs to Enterprises: Why Salesforce CRM Remains the Choice for Every Business Size

Running a modern business requires a robust Salesforce CRM platform that connects teams, organizes customer data, and delivers real-time operational insights. In today’s competitive environment, waiting for information across disconnected systems is no longer practical, especially when modern buyers expect immediate responses across every channel. For years, the software was primarily associated with large corporate […]

Read More
How to Integrate NikoHealth to Salesforce

Healthcare organizations using NikoHealth often need patient, insurance, order, invoice, and prescription data available inside Salesforce. As data grows, manually updating records across systems becomes difficult and can lead to delays, duplicate work, and data inconsistencies. NikoHealth to Salesforce integration helps solve this challenge by automatically synchronizing data between both platforms. Instead of building custom […]

Read More
Flow Orchestrator vs. Traditional Flows: When to Use Each for Salesforce Automation

Businesses use Salesforce automation to reduce manual work, improve efficiency, and automate repetitive business processes. Two commonly used automation approaches inside Salesforce are Traditional Flows and Flow Orchestrator. Traditional Flows are mainly used for simple automation tasks such as updating records, sending notifications, creating tasks, and automating business logic. Flow Orchestrator is designed for more […]

Read More
The Rise of Agentic Government: How AI Agents Are Transforming Public Services

Government technology has often been seen as slower to evolve than the private sector. But Salesforce’s latest research challenges that idea in a big way. In fact, the new findings suggest that public sector organizations may now be moving faster than many businesses when it comes to adopting AI agents and preparing for a more […]

Read More
How To Use Email Service in APEX

Managing approvals, updates, and record changes directly from email can significantly improve efficiency within Salesforce workflows. Instead of logging in, navigating records, and manually updating fields, users can simply respond to emails and trigger automated updates using Email Service in APEX. This approach is especially useful for businesses leveraging Salesforce automation and looking to enhance […]

Read More
Design and Implementation of Salesforce-Jira Task Integration

Businesses have been using Salesforce for CRM operations and Jira for Agile project tracking. However, without integration, teams manually update both systems, leading to data inconsistency and inefficiency.This mechanism establishes a real-time integration between Salesforce and Jira, allowing seamless synchronization of tasks and agile board statuses.  A custom Salesforce dashboard was developed that replicates Jira-style […]

Read More
Our Location worldwide
Indian Flag India
7th Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203669505
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
CA Flag Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818