The Ajax API provides a suite of lightweight REST API endpoints for the development of Shoplazza themes.



The Ajax API can only be used by themes that are hosted by Shoplazza.

Use cases

Possible uses of the Ajax API include:

  • Add products to the cart and update the cart item counter.
  • Display related product recommendations.
  • Suggest products and collections to visitors as they type in a search field.

See the Ajax API reference for a full list of available API endpoints.

Making requests to the API

The Ajax API accepts four types of HTTP requests:

  • GET requests to read cart and some product data
  • POST requests to update the cart for the current session
  • PATCH requests to modify the cart for the current session
  • DELETE requests to delete the cart for the current session

For instance, to fetch the current content of the cart, send a client-side request to the store /api/cart endpoint.

fetch(window.SHOPLAZZA.routes.root + '/api/cart')
  .then(response => response.json())
  .then(data => { /* do something */});

Locale-aware URLs

Stores can have dynamic URLs generated for them when they sell internationally or in multiple languages. When using the Ajax API, it’s important to use dynamic, locale-aware URLs so that you can give visitors a consistent experience for the language and country that they’ve chosen.

The global value window.SHOPLAZZA.routes.root is available to use as a base when building locale-aware URLs in JavaScript. The global value will always end in an empty string, so you can safely use simple string concatenation to build the full URLs.