The UpCart Public API lets you customize your cart, automate workflows, and integrate with third-party apps β whether you're a developer or just getting started.
This guide will walk you through the basics and help you start building custom functionality inside your cart drawer.
Overview
The Public API is a collection of JavaScript functions and event listeners that let you:
React to cart changes β detect when items are added, removed, or updated.
Trigger actions β such as opening or closing the cart programmatically.
Build custom features β inject your own logic or UI components directly inside the cart drawer.
Itβs especially helpful when working in the Custom HTML section of the UpCart editor, where you can use these functions to create unique experiences for shoppers.
What You Need to Get Started
Before using UpCartβs API, make sure you have:
Access to UpCart in your Shopify store
Ensure UpCart is installed and active in your store.A basic understanding of JavaScript
Many customizations use pre-written snippets, but knowing basic JavaScript helps if you want to go beyond the basics.
Adding Your First UpCart API Script
You can start using the API right from your UpCart editor:
1. Go to UpCart Editor β Settings β Custom HTML β Scripts (before load)
2. Paste in your script β for example:
<script> window.upcartOnAddToCart = (id, quantity, item) => { console.log("You just added " + item.title + " to your cart!"); }; </script>3. Save your changes, then test it in your store:
Open Dev Tools (
F12orCtrl + Shift + Jon Windows,Cmd + Option + Jon Mac)Add a product to your cart
Check the Console tab for the message:
β"You just added [product title] to your cart!"
π If you see the message, your first API script is working!
Start Customizing Your Cart
Now that youβre set up, you can use the API to do all sorts of cool things β like automatically opening the cart when items are added, updating custom widgets, or sending analytics events.
For full function references and examples, check out the UpCart Public API Documentation.
More Resources
π§© API FAQ β Troubleshooting tips and common questions
βοΈ Common Uses for UpCart API β Popular code examples and templates
π‘ Customization Docs β Pre-written scripts to help you get started fast
ποΈ Shopifyβs Cart API Documentation β Learn how Shopify handles cart data behind the scenes
π©βπ» Need advanced customizations? Consider hiring a Shopify Expert for more complex integrations.