Getting Started
Configuration
Configure retries, timeout, cache policy, custom fetch, and debugging.
Client configuration
import { createSazitoClient } from '@sazito/client-sdk';
const client = createSazitoClient({
domain: 'mystore.sazito.com',
timeout: 30000,
customFetchApi: fetch,
debug: false,
retry: {
enabled: true,
retries: 3,
retryDelay: 1000,
},
cache: {
products: { enabled: true, ttl: 600000 },
categories: { enabled: true, ttl: 600000 },
cart: { enabled: false },
orders: { enabled: false },
search: { enabled: true, ttl: 300000 },
cms: { enabled: true, ttl: 600000 },
tags: { enabled: true, ttl: 600000 },
entityRoutes: { enabled: true, ttl: 600000 },
},
});Fields (all config keys)
| Field | Type | Required | Notes |
|---|---|---|---|
domain | string | Yes | Store domain without protocol |
timeout | number | No | Global request timeout in ms |
customFetchApi | typeof fetch | No | Override runtime fetch implementation |
debug | boolean | No | Enables request logging |
retry | RetryConfig | No | Retry policy object |
retry.enabled | boolean | No | Enables/disables retry behavior |
retry.retries | number | No | Max retry attempts (0-3) |
retry.retryDelay | number | No | Base delay in ms between retries |
cache | CacheMap | No | Module-level cache configuration |
cache.products | CacheConfig | No | Cache config for products API |
cache.categories | CacheConfig | No | Cache config for categories API |
cache.cart | CacheConfig | No | Cache config for cart API |
cache.orders | CacheConfig | No | Cache config for orders API |
cache.search | CacheConfig | No | Cache config for search API |
cache.cms | CacheConfig | No | Cache config for CMS API |
cache.tags | CacheConfig | No | Cache config for tags API |
cache.entityRoutes | CacheConfig | No | Cache config for entity routes API |
cache.*.enabled | boolean | No | Turns cache on/off for that module |
cache.*.ttl | number | No | Time-to-live in ms for cached GET data |
CacheMap shape:
type CacheMap = {
products?: CacheConfig;
categories?: CacheConfig;
cart?: CacheConfig;
orders?: CacheConfig;
search?: CacheConfig;
cms?: CacheConfig;
tags?: CacheConfig;
entityRoutes?: CacheConfig;
};
type CacheConfig = {
enabled: boolean;
ttl?: number;
};Defaults
If a field is omitted, SDK defaults are used:
| Field | Default |
|---|---|
timeout | 30000 |
retry.enabled | true |
retry.retries | 3 |
retry.retryDelay | 1000 |
cache.products | { enabled: true, ttl: 600000 } |
cache.categories | { enabled: true, ttl: 600000 } |
cache.cart | { enabled: false } |
cache.orders | { enabled: false } |
cache.search | { enabled: true, ttl: 300000 } |
cache.cms | { enabled: true, ttl: 600000 } |
cache.tags | { enabled: true, ttl: 600000 } |
cache.entityRoutes | { enabled: true, ttl: 600000 } |
debug | false |
Per-request overrides
await client.products.get('/product/running-shoe-pro', {
timeout: 5000,
retries: 1,
cache: false,
headers: {
'X-Request-ID': 'req-123',
},
});Supported override keys: timeout, retries, cache, headers, signal.