
Generate Client SDK
Follow this guide to generate the Client SDK for your project
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).
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).
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).
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:
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:
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.
Returns
- A promise that resolves to the updated context.
Expand source
Expand source