Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
forcedotcom avatar

Fetching Webapp Rest Api

  • 1 installs
  • 787 repo stars
  • Updated August 5, 2026
  • forcedotcom/afv-library

Calls Salesforce Chatter, Connect REST, Apex REST, UI API, or Einstein LLM endpoints via the Data SDK fetch method when GraphQL is insufficient.

About

Guides using sdk.fetch from the Salesforce Data SDK to call REST endpoints when GraphQL is not enough, with auth, CSRF, and base URL handled by the SDK. A developer uses it to hit Chatter, Connect REST, Apex REST, UI API, or Einstein LLM APIs.

  • Uses project API version via __SF_API_VERSION__ with 65.0 fallback
  • Always optional-chains sdk.fetch and handles unavailable fetch

Fetching Webapp Rest Api by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #3,836 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/forcedotcom/afv-library --skill fetching-webapp-rest-api

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
repo stars787
Last updatedAugust 5, 2026
Repositoryforcedotcom/afv-library

What it does

Calls Salesforce Chatter, Connect REST, Apex REST, UI API, or Einstein LLM endpoints via the Data SDK fetch method when GraphQL is insufficient.

Files

SKILL.mdMarkdownGitHub ↗

Salesforce REST API via Data SDK Fetch

Use sdk.fetch from the Data SDK when GraphQL is not sufficient. The SDK applies authentication, CSRF handling, and base URL resolution. Always use optional chaining (sdk.fetch?.()) and handle the case where fetch is not available.

Invoke this skill when you need to call Chatter, Connect REST, Apex REST, UI API REST, or Einstein LLM endpoints.

API Version

Use the project's API version. It is typically injected as __SF_API_VERSION__; fallback to "65.0":

declare const __SF_API_VERSION__: string;
const API_VERSION = typeof __SF_API_VERSION__ !== "undefined" ? __SF_API_VERSION__ : "65.0";

Base Path

URLs are relative to the Salesforce API base. The SDK prepends the correct base path. Use paths starting with /services/....

---

Chatter API

User and collaboration data. No GraphQL equivalent.

EndpointMethodPurpose
/services/data/v{version}/chatter/users/meGETCurrent user (id, name, email, username)
const sdk = await createDataSDK();
const response = await sdk.fetch?.(`/services/data/v${API_VERSION}/chatter/users/me`);

if (!response?.ok) throw new Error(`HTTP ${response?.status}`);
const data = await response.json();
return { id: data.id, name: data.name };

---

Connect REST API

File and content operations.

EndpointMethodPurpose
/services/data/v{version}/connect/file/upload/configGETUpload config (token, uploadUrl) for file uploads
const sdk = await createDataSDK();
const configRes = await sdk.fetch?.(`/services/data/v${API_VERSION}/connect/file/upload/config`, {
  method: "GET",
});

if (!configRes?.ok) throw new Error(`Failed to get upload config: ${configRes?.status}`);
const config = await configRes.json();
const { token, uploadUrl } = config;

---

Apex REST

Custom Apex REST resources. Requires corresponding Apex classes in the org. CSRF protection is applied automatically for services/apexrest URLs.

EndpointMethodPurpose
/services/apexrest/auth/loginPOSTUser login
/services/apexrest/auth/registerPOSTUser registration
/services/apexrest/auth/forgot-passwordPOSTRequest password reset
/services/apexrest/auth/reset-passwordPOSTReset password with token
/services/apexrest/auth/change-passwordPOSTChange password (authenticated)
/services/apexrest/{resource}GET/POSTCustom Apex REST resources

Example (login):

const sdk = await createDataSDK();
const response = await sdk.fetch?.("/services/apexrest/auth/login", {
  method: "POST",
  body: JSON.stringify({ email, password, startUrl: "/" }),
  headers: { "Content-Type": "application/json", Accept: "application/json" },
});

Apex REST paths do not include the API version.

---

UI API (REST)

When GraphQL cannot cover the use case. Prefer GraphQL when possible.

EndpointMethodPurpose
/services/data/v{version}/ui-api/records/{recordId}GETFetch a single record
const sdk = await createDataSDK();
const response = await sdk.fetch?.(`/services/data/v${API_VERSION}/ui-api/records/${recordId}`);

---

Einstein LLM Gateway

AI features. Requires Einstein API setup.

EndpointMethodPurpose
/services/data/v{version}/einstein/llm/prompt/generationsPOSTGenerate text from Einstein LLM
const sdk = await createDataSDK();
const response = await sdk.fetch?.(`/services/data/v${API_VERSION}/einstein/llm/prompt/generations`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    additionalConfig: { applicationName: "PromptTemplateGenerationsInvocable" },
    promptTextorId: prompt,
  }),
});

if (!response?.ok) throw new Error(`Einstein LLM failed (${response?.status})`);
const data = await response.json();
return data?.generations?.[0]?.text ?? "";

---

General Pattern

import { createDataSDK } from "@salesforce/sdk-data";

const sdk = await createDataSDK();

if (!sdk.fetch) {
  throw new Error("Data SDK fetch is not available in this context");
}

const response = await sdk.fetch(url, {
  method: "GET", // or POST, PUT, PATCH, DELETE
  headers: { "Content-Type": "application/json", Accept: "application/json" },
  body: method !== "GET" ? JSON.stringify(payload) : undefined,
});

if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();

---

Reference

  • Parent: accessing-data — enforces Data SDK usage for all Salesforce data fetches
  • GraphQL: using-graphql — use for record queries and mutations when possible
  • createRecord from @salesforce/webapp-experimental/api for UI API record creation (uses SDK internally)

Related skills

Backend & APIsintegrationsbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.