Shopify Ajax API
The Ajax API provides a suite of lightweight REST API endpoints for development ofShopify themes.
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 theAjax API referencefor a full list of available API endpoints.
Making requests to the API
Anchor link to section titled "Making requests to the API"The Ajax API accepts two types of HTTP requests:
GET
requests to read cart and some product dataPOST
requests to update the cart for the current session
For instance, to fetch the current contents of the cart, send a client-side request to the store’s/cart.js
endpoint.
Locale-aware URLs
Anchor link to section titled "Locale-aware URLs"Stores can havedynamic URLsgenerated 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 valuewindow.Shopify.routes.root
is available to use as a base when building locale-aware URLs in JavaScript. The global value will always end in a/
character, so you can safely use simple string concatenation to build the full URLs.
Requirements and limitations
Anchor link to section titled "Requirements and limitations"- This is anunauthenticatedAPI. It doesn’t require access tokens or a client ID to access.
- There are no hardrate limitson the Ajax API. It’s still subject to Shopify’s standard API abuse-prevention measures.
- All API responses return JSON-formatted data.
- The Ajax API can’t be used to read any customer or order data, or update any store data. If you need more extensive access, check theAdmin API.