Services using OCAPI (BETA)

Starting with version 0.10 of the demandware-testing-framework, there have been several serivces that work with the OCAPI provided by Demandware. The intention of the services is to decrease the need for hard-coding products, catagegories, promotions or customers in Specifications. The services should be considered in BETA state until a future release after returned objects from the OCAPI are incorporated into the domain model of the framework.

The Open Commerce APIs (OCAPI) are REST APIs that allow clients, partners and developers to integrate with Demandware easily, allowing you to syndicate your product information.

Shop APIs, allow easier integration with storefront data for use by other systems, apps, etc., with the ultimate goal to complete a transaction. GET, POST and PATCH methods exist for numerous data objects.
Data APIs allow object manipulation within the Demandware platform.

To learn more about Open Commerce APIs, visit our documentation portal https://info.demandware.com/DOC1/index.jsp

Back To Top

Site Configuration

In addition to external configuration (see required configuration) OCAPI requires configuration on the Demandware platform allowing access to OCAPI resources. This documentation is not a replacement for technical documentation provided by Demandware, but will provide a very basic configruation. NOTE: this is not a configuration intended for use in a production or production-like environment.

Store API Configuration

In order to communicate with the Shop API resource, the request needs to contain a "client_id" header or query parameter. This parameter is set inside of the configuration under Administration > Site Development > OCAPI. Follow configuration setup examples in XChange.
NOTE: The client_id can be different than the OAuth based client_id in the Data API (see below)

{
  "_v":"14.2",
  "clients":[
    {
      "client_id":"#-#-#-#-#- REPLACE WITH UNIQUE CLIENT_ID #-#-#-#-#",
      "resources":[
        {
          "resource_id":"/account/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/account/register",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/account/login",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/account/logout",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/account/{id}/addresses",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/add",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_shipping_address",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_billing_address",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_shipping_method",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_customer_info",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_payment_method",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/shipping_methods",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/payment_methods",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/submit",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/categories/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/images",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/availability",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":60
        },
        {
          "resource_id":"/products/{id}/prices",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":300
        },
        {
          "resource_id":"/products/{id}/links",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/promotions",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/options",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/set_products",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/bundled_products",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/links",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/variations",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/product_search",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/product_search/availability",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":60
        },
        {
          "resource_id":"/product_search/images",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "config":{
            "search_result.hits.image:view_type":"large",
            "search_result.variation_attributes.values.image:view_type":"medium",
            "search_result.variation_attributes.values.image_swatch:view_type":"swatch"
          },
          "cache_time":900
        },
        {
          "resource_id":"/product_search/prices",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":300
        },
        {
          "resource_id":"/product_search/variations",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/promotions",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/promotions/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/site",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/folders/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/content_search",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/content/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        }
      ]
    }
  ]
}

Data API

{
  "_v":"14.2",
  "clients":[
    {
      "client_id":"#-#-#-#-#- REPLACE WITH UNIQUE CLIENT_ID FOUND IN https://accounts.demandware.com #-#-#-#-#",
      "resources":[
        {
          "resource_id":"/customers",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/customer_search",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/customers/{customer_no}",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        }
      ]
    }
  ]
} 

OAuth Configuration

Demandware has set up the Data API to use OAuth tokens in order to access any resources within the service. The framework obtains the OAuth token for communiction but needs the required client_id set up inhtts://account.demandware.com.
NOTE: The client_id is ONLY available from main account site. Recommend using the same client_id for the DataAPI as the StoreAPI (simply said, use the DataAPI client_id in the configuration for StoreAPI)

Back To Top