├── README.md ├── fetch-all-stores-collections ├── README.md ├── getAllCollections.js └── getSingleCollectionInfo.js ├── fetch-cartjs └── fetchcart.js ├── fetch-collection-data ├── fetch-single-collection.js └── readme.md ├── fetch-product-data └── fetchproduct.js ├── fetch-shop-data └── fetchshop.js └── get-and-transfer-cart-cookie ├── getCartCookie.js └── setCartCookie.js /README.md: -------------------------------------------------------------------------------- 1 | # 🛍 Shopify Console AJAX API Cheat Sheet 2 | 3 | A collection of scripts to quickly fetch and inspect various data points from a Shopify store using the browser's console. These scripts utilize the AJAX API provided by Shopify to retrieve real-time data from the storefront. 4 | 5 | --- 6 | ![gif example](https://github.com/lucasaraujo45/shopify-dev-console/assets/29403436/a30f8b10-1270-41d8-9889-c4878510b556) 7 | 8 | --- 9 | 10 | ## 🚀 Getting Started 11 | 12 | 1. Navigate to your Shopify store in a web browser. 13 | 2. Open the browser's developer console. (Usually `Ctrl + Shift + I` or `Cmd + Option + I`) 14 | 3. Copy and paste the desired script from this repository into the console. 15 | 4. Hit `Enter` to execute the script and view the results. 16 | 17 | --- 18 | 19 | ## 📂 Scripts Overview 20 | 21 | ### 🛒 [Fetch All Store Collections](./fetch-all-stores-collections) 22 | 23 | This script fetches all collections available in the store by paginating through the results to ensure complete retrieval. 24 | 25 | ### 🛍 [Fetch Cart Data](./fetch-cartjs) 26 | 27 | Fetches the current cart data, which includes details about items added to the cart, cart attributes, and more. 28 | 29 | ### 📦 [Fetch Specific Collection Data](./fetch-collection-data) 30 | 31 | Retrieves data for a specific collection using its handle. This can be useful for inspecting products within a particular collection. 32 | 33 | ### 🏷 [Fetch Specific Product Data](./fetch-product-data) 34 | 35 | Fetches data for a specific product by its handle. This provides detailed information about product variants, pricing, and other related attributes. 36 | 37 | ### 🏪 [Fetch Shop Data](./fetch-shop-data) 38 | 39 | Gathers general data about the Shopify store, such as the shop's name, currency, email, and other metadata. 40 | 41 | ### 🍪 [Manage Shop Cart Cookie](./get-and-transfer-cart-cookie) 42 | 43 | By extracting the cart's unique token, troubleshooting cart-related issues becomes more efficient, allowing for direct examination of user-reported cart anomalies by recreating the exact cart state in any browser or device. This snippet is great for diagnosing and addressing cart-specific challenges in real-time. 44 | 45 | --- 46 | 47 | ## Requirements and limitations 48 | - This is an unauthenticated API. It doesn’t require access tokens or a client ID to access. 49 | - There are no hard rate limits on the Ajax API. It’s still subject to Shopify’s standard API abuse-prevention measures. 50 | - All API responses return JSON-formatted data. 51 | - 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 the Admin API. 52 | 53 | --- 54 | 55 | ## 💡 Contributing 56 | 57 | Contributions are welcome! If you have additional scripts or improvements to share, please make a pull request or open an issue to discuss the changes. 58 | 59 | --- 60 | 61 | ## 📜 License 62 | 63 | This project is open source and available under the MIT License. Use these scripts responsibly and ethically. 64 | -------------------------------------------------------------------------------- /fetch-all-stores-collections/README.md: -------------------------------------------------------------------------------- 1 | Shopify Collection Fetcher 2 | 3 | A set of scripts to fetch collections from a Shopify store using the AJAX API. These scripts provide methods to fetch a limited set of collections or all collections by paginating through the results. 4 | Contents 5 | 6 | getAllCollections.js: Fetches all collections by making multiple requests and aggregating the results. 7 | fetch-collection.js: Fetches the first 30 collections without pagination. 8 | 9 | Usage 10 | 1. Using getAllCollections.js 11 | 12 | To fetch all collections: 13 | 14 | Open your Shopify store in a web browser. 15 | Launch the browser's developer console. 16 | Copy and paste the contents of getAllCollections.js into the console and hit Enter. 17 | The script will print all collections to the console once it completes. 18 | 19 | 2. Using fetch-collection.js 20 | 21 | To fetch the first 30 collections: 22 | 23 | Open your Shopify store in a web browser. 24 | Launch the browser's developer console. 25 | Copy and paste the contents of fetch-collection.js into the console and hit Enter. 26 | The script will print the first 30 collections to the console. 27 | -------------------------------------------------------------------------------- /fetch-all-stores-collections/getAllCollections.js: -------------------------------------------------------------------------------- 1 | let allCollections = []; 2 | 3 | function fetchCollections(page = 1) { 4 | fetch(`/collections.json?page=${page}&limit=50`) 5 | .then(response => response.json()) 6 | .then(data => { 7 | if (data.collections.length) { 8 | allCollections = allCollections.concat(data.collections); 9 | // Recursively fetch the next page 10 | fetchCollections(page + 1); 11 | } else { 12 | // All collections have been fetched 13 | console.log(allCollections); 14 | } 15 | }); 16 | } 17 | 18 | fetchCollections(); 19 | -------------------------------------------------------------------------------- /fetch-all-stores-collections/getSingleCollectionInfo.js: -------------------------------------------------------------------------------- 1 | fetch('/collections.json') 2 | .then(response => response.json()) 3 | .then(data => console.log(data)); 4 | -------------------------------------------------------------------------------- /fetch-cartjs/fetchcart.js: -------------------------------------------------------------------------------- 1 | fetch('/cart.js') 2 | .then(response => response.json()) 3 | .then(data => console.log(data)) 4 | -------------------------------------------------------------------------------- /fetch-collection-data/fetch-single-collection.js: -------------------------------------------------------------------------------- 1 | fetch('/collections/collection-handle.js') 2 | .then(response => response.json()) 3 | .then(data => console.log(data)); 4 | -------------------------------------------------------------------------------- /fetch-collection-data/readme.md: -------------------------------------------------------------------------------- 1 | Fetches data for a specific collection using its handle. 2 | Replace collection-handle with the handle of the collection you want to inspect. 3 | -------------------------------------------------------------------------------- /fetch-product-data/fetchproduct.js: -------------------------------------------------------------------------------- 1 | fetch('/products/product-handle.js') 2 | .then(response => response.json()) 3 | .then(data => console.log(data)); 4 | -------------------------------------------------------------------------------- /fetch-shop-data/fetchshop.js: -------------------------------------------------------------------------------- 1 | fetch('/shop.js') 2 | .then(response => response.json()) 3 | .then(data => console.log(data)); 4 | -------------------------------------------------------------------------------- /get-and-transfer-cart-cookie/getCartCookie.js: -------------------------------------------------------------------------------- 1 | var cartToken = document.cookie.split('; ').find(row => row.startsWith('cart=')).split('=')[1]; 2 | console.log("Cart Token:", cartToken); 3 | -------------------------------------------------------------------------------- /get-and-transfer-cart-cookie/setCartCookie.js: -------------------------------------------------------------------------------- 1 | document.cookie = "cart=YOUR_CART_TOKEN_HERE; path=/"; 2 | console.log("Cart Token Set!"); 3 | 4 | //the cart cookie should be the string of characters you got from running getCartCookie script 5 | --------------------------------------------------------------------------------