SALESFORCE_APIS
Overview
The SALESFORCE_APIS
function retrieves available Salesforce REST API endpoints for a given instance and access token. This is useful for discovering which API services are available for your Salesforce org and for integration or automation tasks. For more information, see the Salesforce REST API Quick Start and the Salesforce REST API Reference .
This example function is provided as-is without any representation of accuracy.
Usage
To use the function in Excel:
=SALESFORCE_APIS(instance_url, token)
instance_url
(string, required): Salesforce instance URL (e.g., https://MyDomainName.my.salesforce.com )token
(string, required): Salesforce OAuth access token
The function returns a 2D list with columns [Service, URL Path]. If credentials are invalid, returns an error message as a string.
Examples
Example 1: List available APIs
In Excel:
=SALESFORCE_APIS("https://MyDomainName.my.salesforce.com", "00Dxx0000001gPFTAY!AR8AQ...")
Expected output:
Service | URL Path |
---|---|
sobjects | /services/data/v63.0/sobjects |
tooling | /services/data/v63.0/tooling |
… | … |
If credentials are invalid: | You need to replace Salesforce instance_url and token with your own. |
How to Acquire a Salesforce Access Token
See the Salesforce REST API Quick Start
To use the SALESFORCE_APIS
function, you need a valid Salesforce OAuth access token. Follow these steps to obtain one using the Salesforce CLI:
- Install the Salesforce CLI and ensure it is available in your PATH.
- Have a Salesforce user account with API access.
Open Windows PowerShell and run:
sf org login web --alias dev-instance
- This opens a browser window for login. After login, credentials are stored under the alias
dev-instance
.
Run the following command to display your access token:
sf org display --target-org dev-instance --json
- Look for the
accessToken
field in the output. This is your API key for use in Excel or API calls. - Copy the new access token and use it as the
token
parameter in theSALESFORCE_APIS
function.
Python Code
import requests
from requests.exceptions import HTTPError
def salesforce_apis(instance_url, token):
"""
Retrieves available Salesforce REST APIs and returns them as a 2D list.
Args:
instance_url (str): Salesforce instance URL (e.g., https://MyDomainName.my.salesforce.com)
token (str): Salesforce OAuth access token
Returns:
list: 2D list with columns [Service, URL Path]. First row contains headers, or a string error message if credentials are invalid or missing.
"""
# Ensure instance_url doesn't end with a slash
instance_url = instance_url.rstrip('/')
proxy_url = "https://cors.boardflare.com/"
# Construct the endpoint URL
url = f"{proxy_url}{instance_url}/services/data/v63.0/"
# Set up the headers with the authorization token
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
try:
response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()
result = [["Service", "URL Path"]]
for service_name, url_path in data.items():
result.append([service_name, url_path])
return result
except HTTPError:
return "Invalid Salesforce instance_url or token. (HTTP error)"
except Exception:
return "An error occurred. Please check your instance_url and token."
Live Notebook
Edit this function in a live notebook .