API Explorer

The API Explorer tool allows application developers to interactively explore the Open Commerce APIs in a few ways:

  • Browse and review APIs.
  • Test APIs by launching requests.

It’s built on Swagger-UI and uses Swagger 2.0 specs that get delivered by the meta APIs.

  • Make sure that your user account has the Documentation User role.

  • Navigate to https://api-explorer.commercecloud.salesforce.com.

  • Authenticate yourself via Account Manager.

  • Get the Swagger API schema from metadata. For the Digital API, you may have to authenticate your client application using a client id and password. If you provide a different Swagger-compatible meta API instead of a Digital meta API, then the default Swagger behavior applies, and no credentials are required.

    You can access the demo metadata at the default pre-populated URL (https://demo-ocapi.demandware.net/s/-/dw/meta/v1/rest) using the demo client id {your_own_client_id} and password {your_own_client_id}.

  • When the metadata is validated, the APIs are displayed.

You can connect API Explorer to a different system as follows:

  1. Enter the target system URL in the field at the top of the page. For example, if the instance is at sandbox_domain.net, the URL might be https://sandbox_domain.net/s/-/dw/meta/v1/rest.
  2. Click Authorize. This opens the Available Authorizations popup.
  3. Click Logout.
  4. Enter the appropriate Client ID and Password for the system and click Authorize.
  5. Click Dismiss to close the popup.
  6. Click Explore to load the metadata from the new target system.

The navigation bar at the top of the page includes dropdown lists for selecting the specific API and version. Selecting an API refreshes the values available in the version dropdown. For OCAPI, you can view any version of the Data, Shop, or Meta APIs. Here are some usage examples:

  • View version 23.1 of the Shop API:
    1. Select shop from the Select API dropdown. This action refreshes the page so the Select API Version dropdown includes the available versions for the Shop API.
    2. Select 23.1 from the Select API Version dropdown. This action displays the resources in the Shop API version 23.1.
    3. Select a resource to expand its details.
  • Examine the GET /catalogs/{catalog_id} operation.
    1. Select data from the Select API dropdown list. This action refreshes the page so the Select API Version dropdown includes the available versions for the Data API.
    2. Select 23.1 from the Select API Version dropdown list. This action displays the resources in the Data API version 23.1.
    3. Select the catalogs resource. It expands to display the available endpoints.
    4. Select the GET /catalogs/{catalog_id} operation. It expands to display the details of this endpoint:
      • Implementation Notes
      • Response Class (Status default) (If the operation requires authorization, then a red exclamation point icon appears on the right side of this section.)
        • Model
        • Example Value
        • Response content type
      • Parameters
      • Response Messages

Here's an example of launching a request from the explorer.

  1. Select data from the Select API dropdown list. This action refreshes the page so the Select API Version dropdown includes the available versions for the Data API.

  2. Select 23.1 from the Select API Version dropdown list. This action displays the resources in the Data API version 23.1.

  3. Select the catalogs resource. It expands to display the available endpoints.

  4. Select the GET /catalogs/{catalog_id} operation. It expands to display the details of this endpoint.

  5. Enter electronics-catalog in the catalog_id parameter.

  6. Launch the request by clicking Try it out! The request and response are displayed. A successful call returns HTTP response code 200 and information about the specified catalog.

    You can copy the Curl request displayed here and paste it directly into a terminal.

You can use the Shop API to launch HTTP requests against specific sandboxes. To do that, enter the site ID of the sandbox (for example, SiteGenesis) in the Write Site Id field.

The Write Site Id field is only visible when shop is selected from the API dropdown.

You may need to log out in order to use different client credentials. Follow these steps to log out:

  1. Click Authorize at the top of the page. This action opens the Available Authorizations dialog.
  2. Click Logout in the dialog. This refreshes the page.