> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackfront.digital/llms.txt
> Use this file to discover all available pages before exploring further.

# Services Reference

# Services Reference

All services are accessible via `useStackfront()` and can be used imperatively outside React components.

## ApiClient

HTTP client for the Stackfront REST API.

```ts theme={null}
class ApiClient {
  get<T>(path: string): Promise<T>;
  post<T>(path: string, body?: unknown): Promise<T>;
  put<T>(path: string, body?: unknown): Promise<T>;
  delete<T>(path: string): Promise<T>;
  setCustomerId(id: string | undefined): void;
  getConfig(): Promise<SdkConfigResponse>;
}
```

## StorefrontClient

GraphQL client for the Shopify Storefront API.

```ts theme={null}
class StorefrontClient {
  init(shopDomain: string, storefrontToken: string, apiVersion?: string): void;
  get isReady(): boolean;
  request<TData>(query: string, options?: { variables?: Record<string, unknown> }): Promise<TData>;
}
```

## StorageService

AsyncStorage wrapper for local persistence.

```ts theme={null}
class StorageService {
  getItem(key: string): Promise<string | null>;
  setItem(key: string, value: string): Promise<void>;
  removeItem(key: string): Promise<void>;
  getObject<T>(key: string): Promise<T | null>;
  setObject(key: string, value: unknown): Promise<void>;
}
```

## EventService

Batched event tracking pipeline.

```ts theme={null}
class EventService {
  init(): Promise<void>;
  destroy(): void;
  track(eventType: string, properties?: Record<string, unknown>): void;
  flush(): Promise<void>;
}
```

## DeviceService

Push notification device registration and management.

```ts theme={null}
class DeviceService {
  init(oneSignalAppId: string): Promise<void>;
  registerDevice(): Promise<void>;
  linkCustomer(customerId: string): Promise<void>;
  unsubscribe(): Promise<void>;
  getPreferences(customerId: string): Promise<NotificationPreference>;
  updatePreferences(customerId: string, request: UpdatePreferencesRequest): Promise<NotificationPreference>;
  getPlayerId(): string | null;
  requestPermission(): Promise<boolean>;
}
```

## ConfigService

Remote SDK configuration.

```ts theme={null}
class ConfigService {
  fetchConfig(): Promise<SdkConfigResponse>;
}
```

## ProductService

Product and collection queries via Storefront GraphQL.

```ts theme={null}
class ProductService {
  getProducts(first?: number, after?: string): Promise<unknown>;
  getProduct(handle: string): Promise<unknown>;
  getProductById(id: string): Promise<unknown>;
  getCollections(first?: number, after?: string): Promise<unknown>;
  getCollection(handle: string): Promise<unknown>;
  searchProducts(query: string, first?: number): Promise<unknown>;
}
```

## CartService

Cart CRUD via Storefront GraphQL mutations.

```ts theme={null}
class CartService {
  create(lines: CartLineInput[]): Promise<unknown>;
  get(): Promise<unknown | null>;
  addLines(lines: CartLineInput[]): Promise<unknown>;
  updateLines(lines: { id: string; quantity: number }[]): Promise<unknown>;
  removeLines(lineIds: string[]): Promise<unknown>;
  updateBuyerIdentity(identity: CartBuyerIdentityInput): Promise<unknown>;
  getCheckoutUrl(): Promise<string | null>;
  clear(): Promise<void>;
}
```

## CustomerService

Customer authentication, profile, and orders.

```ts theme={null}
class CustomerService {
  setAccessToken(token: string | null): void;
  getAccessToken(): string | null;
  create(input: CustomerCreateInput): Promise<unknown>;
  login(input: CustomerAccessTokenCreateInput): Promise<CustomerAccessToken>;
  logout(): Promise<void>;
  getCustomer(): Promise<unknown>;
  getOrders(): Promise<unknown[]>;
  recoverPassword(email: string): Promise<unknown>;
}
```

## LoyaltyService

Points, tiers, transactions, and referral program.

```ts theme={null}
class LoyaltyService {
  getAccount(customerId: string, customerEmail?: string): Promise<LoyaltyAccountSdkResponse>;
  getTransactions(customerId: string, page?: number, pageSize?: number): Promise<LoyaltyTransactionResponse[]>;
  redeem(request: RedeemPointsRequest): Promise<RedeemPointsResponse>;
  getReferral(customerId: string): Promise<ReferralSdkResponse>;
  trackReferral(request: TrackReferralRequest): Promise<void>;
}
```

## ReviewService

Product review management.

```ts theme={null}
class ReviewService {
  getProductReviews(productId: string, page?: number, pageSize?: number): Promise<ProductReviewsSdkResponse>;
  submitReview(request: CreateProductReviewRequest): Promise<ProductReview>;
  markHelpful(reviewId: string, request: ReviewHelpfulRequest): Promise<void>;
}
```

## StoryService

Story/collection highlights.

```ts theme={null}
class StoryService {
  getStories(): Promise<SdkStoriesResponse>;
  recordView(request: StoryViewedRequest): Promise<void>;
  recordTap(request: StoryTappedRequest): Promise<void>;
  recordPollVote(request: StoryPollVoteRequest): Promise<StoryPollVoteResponse>;
}
```

## SocialProofService

Live social proof signals.

```ts theme={null}
class SocialProofService {
  trackProductView(request: ProductViewEventRequest): Promise<void>;
  getSignals(productId: string): Promise<SocialProofSignalsResponse>;
}
```

## IntegrationService

Third-party integration data.

```ts theme={null}
class IntegrationService {
  getData(slug: string, dataType: string, entityId?: string): Promise<IntegrationDataResponse>;
}
```

## WishlistService

Local wishlist persistence.

```ts theme={null}
class WishlistService {
  init(): Promise<void>;
  add(productId: string): Promise<void>;
  remove(productId: string): Promise<void>;
  toggle(productId: string): Promise<void>;
  isInWishlist(productId: string): boolean;
  getItems(): WishlistItem[];
}
```

## BillingService

App subscription billing.

```ts theme={null}
// BillingService is instantiated in StackfrontProvider via:
// const billing = useMemo(() => new BillingService(api), [api]);
// See BillingService.ts for full method signatures.
```
