@openfoodfacts/openfoodfacts-nodejs
    Preparing search index...

    Class QueryApi

    Client for the supported facet queries on the Open Food Facts query service.

    Index

    Constructors

    • Parameters

      • fetch: (input: string | Request | URL, init?: RequestInit) => Promise<Response>
      • options: { baseUrl?: string } = {}

      Returns QueryApi

    Methods

    • Return the number of distinct values in a facet, optionally restricted by a product filter.

      Parameters

      Returns Promise<number>

    • Return grouped facet values and product counts. This method uses the service's supported $match, $group, $limit, and $skip stages.

      Parameters

      Returns Promise<Required<{ _id?: string; count: number }>[]>

      const brands = await client.query.getFacetValues("brands_tags", {
      filter: { countries_tags: "en:france" },
      limit: 20,
      });