In order to optimize requests you can include referenced documents in a single request. To include referenced documents, use the include
parameter with a comma separated value containing the schemas you want to reference.
include: categories,related_products
includeFormat: list
To include everything you can use *
.
Mind tha the maximum number of included documents that can be returned is 500.
Format
There are 4 available formats:
- list (default)
- bySchema: Grouped by Schema
- byId: Keyed by Id
- bySchemaId: Grouped by Schema and keyed by Id
By default the included documents a returned as a flat list
Example list
:
{
"included": [
{
"id": "ffff8ada-d562-4479-8a73-3fd613f62a4d",
"schema": "brands",
"content": {
"title": "Giffard",
"slug": "giffard"
},
"subdocs": [],
"validation": []
},
{
"id": "ff2c79da-1813-4075-9499-873835783aec"
},
{
"id": "f12095da-1315-4375-9499-872335783aec"
}
]
}
Example bySchema
:
{
"included": {
"brands": [
{
"id": "ffff8ada-d562-4479-8a73-3fd613f62a4d",
"schema": "brands",
"content": {
"title": "Giffard",
"slug": "giffard"
},
"subdocs": [],
"validation": []
},
{
"id": "0b21800d-92e5-4bac-a5f1-f1577bab40df"
}
],
"stockItems": [
{
"id": "ff2c79da-1813-4075-9499-873835783aec",
"schema": "stockItems"
}
]
}
}
Example byId
:
{
"included": {
"ffff8ada-d562-4479-8a73-3fd613f62a4d": {
"id": "ffff8ada-d562-4479-8a73-3fd613f62a4d",
"schema": "brands",
"content": {
"title": "Giffard",
"slug": "giffard"
},
"subdocs": [],
"validation": []
},
"ff2c79da-1813-4075-9499-873835783aec": {
"id": "ff2c79da-1813-4075-9499-873835783aec"
}
}
}
Example bySchemaId
:
{
"included": {
"brands": {
"ffff8ada-d562-4479-8a73-3fd613f62a4d": {
"id": "ffff8ada-d562-4479-8a73-3fd613f62a4d",
"schema": "brands",
"content": {
"title": "Giffard",
"slug": "giffard"
},
"subdocs": [],
"validation": []
},
"ff2c79da-1813-4075-9499-873835783aec": {
"id": "ff2c79da-1813-4075-9499-873835783aec"
}
},
"stockItems": {
"ff2c79da-1813-4075-9499-873835783aec": {
"id": "ff2c79da-1813-4075-9499-873835783aec",
"schema": "stockItems"
}
}
}
}