Skip to main content

Introduction to Upcart's Public API

Learn how to get started with Upcart's API, add scripts, test changes, and customize your cart with ease.

Updated yesterday

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 (F12 or Ctrl + Shift + J on Windows, Cmd + Option + J on 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

Did this answer your question?