getBlocks
Get all blocks.
Description
Fetches blocks, optionally filtered by type, and resolves to an IBlocksResponse with the blocks in items and their count in total. offset and limit paginate the list. Unless traficLimit: true is set in the defineOneEntry config, the SDK also loads the products of each product_block and similar_products_block block, with the same offset and limit.
.getBlocks(
,
,
,
,
);
Parameters schema
Schema
type: BlockType
Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "frequently_ordered_block" | "trending_block" | "recently_viewed_block" | "repeat_purchase_block" | "slider_block" | "personal_recommendations_block" | "cart_complement_block" | "cart_similar_block" | "wishlist_similar_block" | "form" | "common_page" | "common_block" | "order" | "service" | "external_page" | "discount" (see BlockType). When omitted, blocks of all types are returned. A type no block has (e.g. "product", which is a product type, not a block type) gives an empty list, not an error.
example: 'product_block'
langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"
offset: number
Number of records to skip. Default: 0. offset + limit must not exceed 200; a larger window is rejected with 400.
example: 0
limit: number
Maximum number of records to return. Default: 30.
example: 30
markers: string[]
Optional list of block markers to restrict the result to. Sent as the markers field of the request body; when omitted or empty, blocks are not filtered by marker.
example:
[
"product_block",
"trending"
]
Filtering by 'service' currently fails with 400 type must be a valid enum value; this is a known platform issue.
Record limit. If the user group's permission for this method allows only restricted reading, the API returns at most the number of records set in the project settings (10 by default), whatever limit you pass. With full read access, limit works as usual. See Module permissions (opens in a new tab).
Examples
Minimal example
const response = await Blocks.getBlocks();
Example with type
const response = await Blocks.getBlocks('common_block');
Example with all parameters
const response = await Blocks.getBlocks('common_block', 'en_US', 0, 30);
Example response
{
"items": [
{
"id": 3,
"attributeSetIdentifier": null,
"localizeInfos": {
"title": "Block"
},
"version": 0,
"position": 1,
"identifier": "block",
"type": "common_block",
"templateIdentifier": null,
"isVisible": true,
"attributeValues": {}
},
{
"id": 4,
"attributeSetIdentifier": "block",
"localizeInfos": {
"title": "test"
},
"version": 31,
"position": 2,
"identifier": "test",
"type": "common_block",
"templateIdentifier": null,
"isVisible": true,
"attributeValues": {
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
},
"interval": {
"type": "timeInterval",
"value": [
{
"values": [
{
"id": "bbc82c9f-1bc4-4c86-b83c-c062016eb7cb",
"dates": [
"2025-04-14T00:00:00.000Z",
"2025-04-14T00:00:00.000Z"
],
"times": [
[
{
"hours": 9,
"minutes": 0
},
{
"hours": 10,
"minutes": 0
}
],
[
{
"hours": 10,
"minutes": 0
},
{
"hours": 11,
"minutes": 0
}
],
[
{
"hours": 11,
"minutes": 0
},
{
"hours": 12,
"minutes": 0
}
]
],
"intervals": [],
"exceptions": [],
"intervalId": "c6466cd8-c55d-4583-97c5-42b684210f12",
"inEveryWeek": true,
"inEveryMonth": true
}
],
"intervalId": "c6466cd8-c55d-4583-97c5-42b684210f12"
}
],
"isIcon": false,
"position": 1,
"additionalFields": {},
"isProductPreview": false
}
}
}
],
"total": 2
}
Response schema
Schema: IBlocksResponse
total: number
Total number of found records.
example: 100
items: IBlockEntity[]
Blocks in this response.
example:
[
{
"attributeValues": {},
"id": 1,
"identifier": "block1",
"isVisible": true,
"localizeInfos": {
"key": "value"
},
"position": 1,
"templateIdentifier": null,
"type": "product_block",
"version": 1,
"countElementsPerRow": 3,
"quantity": 9,
"similarProducts": {
"total": 0,
"items": []
},
"products": [
{
"id": 1,
"localizeInfos": {
"title": "Product 1"
}
},
{
"id": 2,
"localizeInfos": {
"title": "Product 2"
}
}
]
}
]
items.attributeValues: IAttributeValues
Attribute values keyed by marker; an empty object when there are none.
example:
{
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
}
}
items.id: number
ID of the block.
example: 1234
items.localizeInfos: ILocalizeInfo
Localized data of the block.
example:
{
"title": "Example title"
}
items.version: number
Version number of the block.
example: 1
items.identifier: string
Marker of the block.
example: "block1"
items.type: BlockType
Type of the block.
example: "product_block"
items.position: number
Position of the block, used for sorting.
example: 1
items.templateIdentifier: string | null
Marker of the template used by the block, or null.
example: "template1"
items.isVisible: boolean
Whether the block is visible.
example: true
items.countElementsPerRow: number
Number of items per row in the block, if set.
example: 3
items.quantity: number
Quantity of items in the block, if applicable.
example: 5
items.similarProducts: IProductsResponse
Similar products for the block, as total and items.
example:
{
"total": 10,
"items": []
}
items.products: IProductsEntity[]
Products linked to the block.
example:
[
{
"id": 1,
"localizeInfos": {
"title": "Product 1"
}
},
{
"id": 2,
"localizeInfos": {
"title": "Product 2"
}
}
]