Fetch by Filter

api
  .fetchByFilter({
    filters: [
      {
        operator: '$and',                      // (1)
        filters: [
          {
            field: 'page.formData.type.value', // (2)
            operator: '$eq',
            value: 'content',
          },
          {
            field: 'page.formData.id.value',   // (3)
            operator: '$eq',
            value: 'homepage',
          },
        ],
      },
    ],
    locale: 'de_DE',              // (4)
    page: 1,                      // (5)
    pagesize: 10,                 // (6)
    normalized: true              // (7)
  })
  .then((result) => console.log('Found Items: ', result))
  .catch((error) => console.error('Failed to fetch items', error));
  1. Logical operator to combine multiple filters
  2. Filter by the content type
  3. Filter by the content ID
  4. Locale for the response
  5. Page number for pagination (starts at 1)
  6. Number of items per page
  7. Whether to return a normalized response with resolved references

Note

The fetchByFilter method provides more flexible querying capabilities compared to findPage. You can create complex filters using comparison operators ($eq, $ne, $gt, $gte, $lt, $lte, $in, $nin), logical operators ($and, $or, $nor, $not), array operators ($all), and evaluation operators ($regex).

Tip

To improve query performance, consider using the CaaS index fields page.formData.type.value, page.formData.id.value, locale.language and locale.country in your filters, especially for Shop Driven Pages.


Last update: May 19, 2025