The Public API for Smart Wishlist is a primitive API, which can be used to fetch the Wishlist data. It can be used for multitude of purposes for e.g. populating the wishlist data in any type of display including modals, previews or any random page of the store. It can also be used to design a brand new custom wishlist page. When used along with Callback functions, it could be used to create an immersive wishlist experience.
NOTE: The Public API is a read-only API and supports only GET method. It doesn’t support ADD/REMOVE operations on Wishlist. We are separately launching the REST API, which shall support all native wishlist operations using POST/PUT methods.
The public API doesn’t require any authentication. But it can only be accessed using your store’s domain and the Wishlist URL.
The API can be requested using the same path as your wishlist page (/a/wishlist), by passing few additional parameters. In case your wishlist is accessible at a path other than /a/wishlist, you need to replace this with the altered wishlist path.
1. Path for accessing wishlist data of registered users:
2. Path for accessing wishlist data of non-registered users:
1. type: It’s mandatory and its value must be api in order for the API to work.
2. customerid: It is a unique numeric id generated by Shopify for each registered user.
3. wishlistid: It is a unique alphanumeric string generated by the app for each non-registered user.
Important: You must provide either of customerid or wishlistid in the path, depending on the type of user, while making an API request. In case both is present in the path or none is present, the response could be unpredictable.
4. version As of now its only acceptable value is 1. Its usage would ensure that your implementation won’t break even if we introduce changes in future.
The response in both the cases is in the JSON format. It contains a minimum of following fields:
1. count: The number of items returned
2. type: The response type (success/error)
3. message: Relevant message if an error occurs
4. items: Array of wishlist items in JSON format.
5. id: A numeric id generated by Shopify for each product.
6. title: The title of the product.
7. handle: The handle can be used to determine the URL of the product. A typical product URL would look like www.yourstore.com/products/handle
8. variant_id: It is a numeric Id generated by Shopify and is unique across variants of all products.
9. is_true_variant: If set to 1, it means that the user has added this particular variant to the wishlist. If set to 0, it means that user may not have added the selected variant to the wishlist and in such cases the chosen variant need to be confirmed by the user before adding the item to cart.
10. variant_count: The total number of available variants of the product.
11. variant_title: The title of the product variant
12. variant_price: The price of the variant and consequently the price to be displayed to the user.
13. image: The product image to be displayed
Sample Request Code
The following code uses jQuery’s ajax function to fetch the wishlist data
A typical sample response is given below: