Skip to content

Facets REST

When to Use

When building a headless/decoupled frontend and need facet data in API responses.

Decision: Facets REST Sub-Module

Module: facets_rest

Provides FacetsSerializer — a Views REST display style plugin that includes facet data in the REST response alongside search results.

Pattern: Setup

  1. Enable: drush en facets_rest
  2. Create a Views REST export display using your Search API index
  3. Select "Facets Serializer" as the display style
  4. Create facets for this display's facet source
  5. Use the array widget for facets used in REST

Pattern: Response Format

The REST response includes a facets key with structured facet data — values, counts, active states, and URLs for each facet item.

Common Mistakes

  • Using the links or checkbox widget for REST facets — Use the array widget so the response contains raw structured data instead of rendered HTML.

See Also

  • Widgets — ArrayWidget for programmatic output
  • Facet Sources — REST display as facet source
  • Reference: modules/facets_rest/