
Generate Client SDK
Follow this guide to generate the Client SDK for your project
Initialization
The generated client can be used in two ways:Direct client import
Factory function with configuration
For global configuration like proxy URLs:Configuration
createClient(config?)
Create a configured client instance.
Parameters
config(object, optional): Global configuration options.proxyUrl(string, optional): Proxy URL to use for all requests (e.g.,/api/frontstack). The client will concatenate this with the original API path (e.g.,/api/frontstack/block). The proxy should forward requests to the target URL specified in thefs-target-urlheader. This is useful to prevent CORS issues when making requests from a browser.
Returns
- A configured client instance with all client methods.
Methods
client.block
Fetch a block by its key.
Parameters
name(string): The name of the block to fetch.- Example:
'ProductCard'
- Example:
key(string): The key of the block to fetch.- Example:
'123'
- Example:
config(object, optional): Additional configuration options.requestUrl(string, optional): A URL that will be used to track the origin of the request.contextKey(string, optional): A token that identifies the user’s context state (locale, region).proxyUrl(string, optional): Proxy URL to use for this request, overriding any global configuration.
Returns
- A promise that resolves to the block response.
Expand source
Expand source
Usage
client.listing
Fetch a listing with optional parameters and query options.
Parameters
name(string): The name of the block to fetch.- Example:
'CategoryListing'
- Example:
params(object, optional): The parameters to pass to the listing.- Example:
{ categoryId: '<category-id>' }
- Example:
config(object, optional): Additional configuration options.query(object, optional): Query parameters to pass to the listing.filter(array): An array of filter objects to filter results.sort(array): An array of sorting options to sort results.search(string): A text search query.limit(number): Limit the number of results returned.page(number): Paginate results.
requestUrl(string, optional): A URL that will be used to track the origin of the request.contextKey(string, optional): A token that identifies the user’s context state (locale, region).proxyUrl(string, optional): Proxy URL to use for this request, overriding any global configuration.
Returns
- A promise that resolves to the listing response.
Expand source
Expand source
Usage
client.page
Fetch a page by its slug.
Parameters
slug(string): The URL slug of the page (without protocol).- Example:
demo-shop.com/uk/women/shoes/running
- Example:
config(object, optional): Configuration options.requestUrl(string, optional): A URL that will be used to track the origin of the request.contextKey(string, optional): A token that identifies the user’s context state (locale, region).proxyUrl(string, optional): Proxy URL to use for this request, overriding any global configuration.
Returns
- A promise that resolves to the page data.
Expand source
Expand source
Usage
client.context
Fetch a context by its token.
Parameters
token(string): The token of the context.- Example:
'ae0d4981-c363-4d5a-a49e-1f053d49f2f7'
- Example:
config(object, optional): Configuration options.proxyUrl(string, optional): Proxy URL to use for this request, overriding any global configuration.
Returns
- A promise that resolves to the context and token.
Expand source
Expand source
client.contextList
Fetch a list of contexts, optionally using a token.
Parameters
token(string, optional): The token of the context.- Example:
'ae0d4981-c363-4d5a-a49e-1f053d49f2f7'
- Example:
config(object, optional): Configuration options.proxyUrl(string, optional): Proxy URL to use for this request, overriding any global configuration.
Returns
- A promise that resolves to an array of contexts and a context token.
Expand source
Expand source
client.contextUpdate
Update a context with new region and locale.
Parameters
context(object): The context details to update.region(string): The region to update.locale(string): The locale to update.
token(string): The token of the context.config(object, optional): Configuration options.proxyUrl(string, optional): Proxy URL to use for this request, overriding any global configuration.
Returns
- A promise that resolves to the updated context.
Expand source
Expand source