Documentation Index
Fetch the complete documentation index at: https://docs.enad.io/llms.txt
Use this file to discover all available pages before exploring further.
A TypeScript SDK for interacting with the Enad API.
Provides a clean, type-safe interface with all responses standardized to [data, error].
Installation
pnpm add @enadhq/enad-ts-sdk
# or
npm install @enadhq/enad-ts-sdk
# or
yarn add @enadhq/enad-ts-sdk
import { ShopperClient } from "@enadhq/enad-ts-sdk";
// Minimum configuration
export const client = new ShopperClient({
apiKey: "api-key-123",
appId: "app-id-UUID",
groupId: "store-group-slug",
defaultLocale: "en", // Optional. Recommended to add a defaultLocale
defaultMarket: "us", // Optional. Recommended to add a defaultMarket
})
Usage examples
- Fetch a single product by SKU
const [product, error] = await client.products.getBySku("SKU123");
if (error) {
console.error("Failed to fetch product:", res.error.message);
} else {
console.log("Product id:", product.id);
}
- Fetch multiple products by SKUs
const [skus, error] = await client.products.getBySkus(["SKU123", "SKU456"]);
if (error) {
console.error("Failed to fetch products:", error.message);
} else {
console.log("skus:", skus);
}
- Get category by slug
const [result, error] = await client.categories.getBySlug("laptops", { per_page: 10, include_child_category_products: true});
if (error) {
console.error("Failed to fetch category:", error.message);
} else {
console.log("result:", result);
}
Clients
There is clients available:
ShopperClient: For shopper-facing operations like fetching products, categories, and collections.
CustomerClient: For customer specific operations like getting user details, whishlist etc.
import { ShopperClient } from "@enadhq/enad-ts-sdk";
import { CustomerClient } from "@enadhq/enad-ts-sdk";
Modules
ShopperClient
The SDK is organized into modules that group related functionality. Each module exposes methods for interacting with specific parts of the Enad API.
products: Methods for fetching and searching products.
brands: Methods for fetching brand information.
categories: Methods for fetching product categories.
collections: Methods for fetching product collections.
facets: Methods for working with product facets.
redirects: Methods for handling URL redirects.
series: Methods for fetching product series.
tags: Methods for fetching product tags.
variants: Methods for fetching product variants.
CustomerClient
user: Methods for retrieving and managing user information.
All SDK methods return a standardized tuple-style response, making it simple and predictable to handle results:
type ApiResponse<T> =
| [data: T, error: null]
| [data: null, error: ApiError];
This design allows for easy destructuring and explicit naming, for example:
const [tags, error] = await client.tags.getAll();
if (error) {
console.error("Failed to fetch product:", error.message);
return;
}
console.log("Product:", data);
Because of the response contract:
- data is guaranteed to be defined if error is null.
- error is guaranteed to be defined if data is null.
This means you can safely use one or the other without additional null checks, and you don’t need try/catch blocks for simple error handling.