Skip to content

Class: ProductAPI

Product API client for managing products and product-related data. Provides methods to retrieve products, review summaries, and metadata.

Constructors

Constructor

ts
new ProductAPI(http: HttpClient, apiKey: string): ProductAPI;

Parameters

http

HttpClient

apiKey

string

Returns

ProductAPI

Methods

getProductReviewMeta()

ts
getProductReviewMeta(productId: string, reviewCode: string): Promise<ProductReviewMeta>;

Retrieves review metadata for a specific product and review code. Used for generating structured data (JSON-LD) for SEO purposes.

Parameters

productId

string

The product ID

reviewCode

string

The review code identifier

Returns

Promise<ProductReviewMeta>

Promise resolving to review metadata

Throws

When the API returns an error

Throws

When a network error occurs

Example

typescript
const meta = await sdk.productAPI().getProductReviewMeta('product-123', 'review-code');
// Use meta.review_meta for structured data

getProductReviewSummary()

ts
getProductReviewSummary(productId: string, groupStatus?: boolean): Promise<ProductReviewSummary>;

Retrieves review summary statistics for a specific product.

Parameters

productId

string

The product ID to get review summary for

groupStatus?

boolean = true

Whether to include group status in summary (default: true)

Returns

Promise<ProductReviewSummary>

Promise resolving to product review summary

Throws

When the API returns an error

Throws

When a network error occurs

Example

typescript
const summary = await sdk.productAPI().getProductReviewSummary('product-123');
console.log(`Average rating: ${summary.average_ratings}`);

getProducts()

ts
getProducts(params?: ProductRequestParams): Promise<Product[]>;

Retrieves products with optional filtering.

Parameters

params?

ProductRequestParams

Optional query parameters for filtering

Returns

Promise<Product[]>

Promise resolving to an array of products

Throws

When the API returns an error

Throws

When a network error occurs

Example

typescript
const products = await sdk.productAPI().getProducts({
  limit: 20,
  status: 'active'
});