npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@lightspeed/ecom-headless

v1.1.2

Published

Headless JS client for Ecwid public API

Readme

@lightspeed/ecom-headless

@lightspeed/ecom-headless is a client-side JavaScript/TypeScript library for interacting with the Ecwid resources. It provides a strongly-typed, modern interface to access store data and trigger UI functionalities within third-party applications, themes, or custom integrations.

This library is designed for both browser and Node.js environments.

Key Features

  • TypeScript First: Strong typing for a better developer experience.
  • npm Package: Easy to integrate via @lightspeed/ecom-headless.
  • Read-Only Data Access: Securely access Products, Categories, Store Profile, etc.
  • Modern JS: ESM, tree-shakable, using axios for HTTP requests.
  • Cross-Platform: Works in modern browsers and Node.js.

Installation

npm install @lightspeed/ecom-headless

Usage

Here's a base example of how to initialize the API client and retrieve a store profile:

import { initStorefrontApi, getStoreProfile, GetStoreProfileResponse } from '@lightspeed/ecom-headless/api';
import { getStoreId } from '@lightspeed/ecom-headless/storefront';

initStorefrontApi({
  publicToken: 'YOUR_PUBLIC_TOKEN',
  storeId: 'YOUR_STORE_ID',
  baseURL: 'https://app.ecwid.com/api/v3/'
});

const storeId = await getStoreId();
const response: GetStoreProfileResponse = await getStoreProfile({ storeId });

API Overview

This library provides a client-side interface for a subset of the functionalities available in the Ecwid REST API. For a complete list of all available backend API endpoints and their detailed documentation, refer to the official Ecwid API Reference.

The underlying HTTP client is axios. The library focuses on fetching fresh data and does not implement persistent caching.

Key Exports and Functionalities

  • Configuration:
    • getApiConfig(): ApiConfig – Retrieves or sets the current API configuration.
  • Products:
    • searchProducts(params?: SearchProductsParams): Promise<SearchProductsResponse> – Searches for products based on various criteria.
    • getProduct(params: GetProductParams): Promise<GetProductResponse> – Fetches a single product by its ID.
    • (Other product-related methods are available and exported from src/api/products/ as implemented.)
  • Shared Types:
    • PaginatedResponse<T> – Generic type for API responses that include pagination details.
    • SearchParams – Basic type for search parameter objects.
    • SortBy – Enum for available product sort orders.
    • All product-specific types under Product, ProductAttribute, etc., are available and exported from src/api/products/types/.

(The list of available methods will expand as more API endpoints are implemented and exported from the root index.ts file.)

Request Handling

Each call to an API method will result in a new HTTP request. The library does not implement request deduplication or persistent caching.

Error Handling

Methods that return Promises will reject in case of errors (e.g., network issues, invalid parameters, API errors from the backend). Errors will typically be instances of Error or a custom error type derived from it, containing relevant information about the failure. Use try...catch blocks for asynchronous operations.

Security

All API methods provided by this library are public and read-only. Access requires a valid public token, which is used to authenticate requests. The library does not handle or store authentication tokens beyond what is required for public API access. All data transmission is performed over HTTPS.

Platform Compatibility

  • Browsers: Designed for and tested in modern web browser environments (e.g., latest versions of Chrome, Firefox, Safari, Edge).
  • Node.js: Suitable for use in Node.js environments for server-side interactions or scripting. axios provides HTTP request capabilities in Node.js.

Versioning & Changelog

This library adheres to Semantic Versioning (SemVer). A CHANGELOG.md file is maintained in the package root to document changes, additions, and fixes for each version.