Skip to main content

API (window.lantern.api)

The window.lantern.api object is your primary tool for communicating with the Lantern backend from the storefront. It provides a set of methods to perform actions and fetch data, with authentication handled automatically.

Available Methods

The api object comes pre-configured with several methods tailored for common storefront operations.

Usage Example

All API methods are asynchronous and return a Promise. You should use async/await or .then() to handle the response. Here’s an example of how to fetch the current user’s account activity.

Authentication

You do not need to handle authentication headers or tokens manually. The window.lantern.api client automatically manages the user’s session. When a user is logged into their Shopify account, the API client sends authenticated requests on their behalf. If the user is not logged in, the API will behave as an unauthenticated user.