HCL Commerce Version 9.1.6.0 or later

HCL Commerce REST API

The HCL Commerce REST API documentation contains a list of resources that are provided by the HCL Commerce REST API. Each REST resource contains information such as URLs, descriptions, and sample input and output data.

Security considerations

  • For security reasons, Swagger should not be exposed in your live production environment.

    You can restrict it from being exposed in the following ways:

    • If the REST API ports are not required to be exposed externally, ensure that they are blocked by your firewall rules. These ports include 5443, 9443, 8000, 30800, and 30900.
    • If you need to expose these ports:
      1. Disable the REST Discovery API for the Transaction server. For more information, see Enabling and disabling the REST Discovery API.
      2. Ensure that you configure your web server to block access to the following swagger endpoints:
        • https://hostname:5443/wcs/resources/api
        • https://hostname:8000/rest/admin/v2/swagger
        • https://hostname:9443/commerceue/extension/api
        • https://hostname:30900/search/resources/v3/api-docs
        • https://hostname:30800/v3/api-docs
        • HCL Commerce Version 9.1.12.0 or laterhttp://localhost:6643/approvals/v3/api-docs

Swagger user interface

From version 9.1.6 onwards, HCL Commerce supports the OpenAPI 3.0 specification. You can use the Swagger specification to test any RESTful APIs that are documented in OAS files.
Swagger user interface access post 9.1.6
Since the Swagger user interface is not provided with the HCL Commerce Rest APIs from HCL Commerce version 9.1.6 onwards, you must set up a local copy of the editor/user interface to securely view OpenAPI Specs. For more information, see Setting up a local Swagger instance.
To use older Swagger specs generated from annotations, please set the OAS3Enabled property in wc-component.xml to false.
Swagger user interface to access older Swagger specs (1.x)
Since older swagger specs (1.x) are not compatible with latest Swagger editor, you cannot open it on the latest Swagger user interface. Hence, setting up an older version of the Swagger user interface instance is required to view swagger 1.x specs.
Please follow the instructions below to deploy the older Swagger user interface.
  • To install the Swagger user interface locally, visit https://github.com/swagger-api/swagger-ui/tree/v2.2.9.
  • To install the interface using a Docker image:
    • Pull the image using the command docker pull swaggerapi/swagger-ui:v2.2.9
    • Create the container using the command docker run -d -p 8080:8080 swaggerapi/swagger-ui:v2.2.9
Note: If you are using a version prior to 9.1.6, you can continue to use the Swagger user interface. For more information, see Swagger UI and Viewing the REST API using Swagger in pre-9.1.6 versions.

Viewing Swagger specifications

You can view the Swagger specifications here:

Viewing Swagger specifications in the Toolkit or Runtime environment

To view the HCL Commerce Rest APIs, access the Swagger specification at the following addresses.
  • For the HCL Commerce Storefront REST APIs: https://<hostname>:5443/wcs/resources/api.

    To access the OpenAPI3.0 specifications of a particular resource: https://<hostname>:5443/wcs/resources/api/resource/<component>.

    For example, to access the specifications for Price, use the following URL: https://<hostname>:5443/wcs/resources/api/resource/price.

  • For Tooling REST APIs: https://<hostname>:8000/rest/admin/v2/swagger.
  • For XC REST APIs: https://<hostname>:9443/commerceue/extension/api.
  • For Query REST APIs: http://<hostname>:30900/search/resources/v3/api-docs
  • For Ingest REST APIs: http://<hostname>:30800/v3/api-docs
Note: The ports might be different for a Toolkit environment.