API and SDK Demo

Make your first request to the Salesforce Commerce API using the Salesforce Commerce SDK.

Our demonstration uses the Shopper Search API to search for dresses in the catalog of an example storefront.

Start by creating a test project and installing the SDK as a package dependency.

Open a terminal and run the following commands:

Create a file called get-dresses.js and open it in a text editor.

Copy the following demo code, and paste it in the file.

Go back to the terminal and run the demo code:

The output of get-dresses.js looks like this:

For more sample code, see the examples directory in the Commerce SDK repository.

In this demo, we’ve already taken care of the following setup tasks for you:

  • Created a demo sandbox with demo data, including example products.
  • Created a demo API client with both a client ID and client secret.
  • Configured SLAS to work with the demo sandbox and demo API client.

To use the API and SDK with your own B2C Commerce instances, you must complete these setup tasks for yourself. These tasks are covered in the following guides: Configuration Values and Authorization for Shopper APIs.

After you’ve completed the setup tasks, explore the SDK’s README and the API specifications in the Reference section.