Storefront Public JS API Overview
The Storefront Public JS API is a set of unauthenticated HTTP endpoints for storefront themes. Call them from the browser or any HTTP client to fetch products, update the cart, and work with blog content.
Key Features
- Product Management: Retrieve product details and pricing, including support for customizations and tax calculations.
- Cart Operations: Add, update, or remove items from the shopping cart, or clear the cart entirely.
- Blog Interactions: Fetch blog articles, post comments, and manage comment threads.
Error Handling
The API uses standard HTTP status codes to indicate the result of each request:
200 OK: Successful operation.404 Not Found: Resource does not exist.403 Forbidden: Action not permitted (e.g., not the owner).422 Unprocessable Entity: Validation errors (e.g., missing fields).
Example Usage
You can interact with the API using fetch in JavaScript or any HTTP client. For example, to get a product:
fetch('/api/products/123')
.then(res => res.json())
.then(data => console.log(data));Refer to the individual endpoint documentation for details on parameters, request/response formats, and error handling.