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

    Class Robotoff

    Index

    Constructors

    • Parameters

      • fetch: {
            (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
            (input: string | Request | URL, init?: RequestInit): Promise<Response>;
        }
          • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
          • Parameters

            • input: RequestInfo | URL
            • Optionalinit: RequestInit

            Returns Promise<Response>

          • (input: string | Request | URL, init?: RequestInit): Promise<Response>
          • Parameters

            • input: string | Request | URL
            • Optionalinit: RequestInit

            Returns Promise<Response>

      • options: { baseUrl: string } = ...

      Returns Robotoff

    Methods

    • Parameters

      • body: {
            annotation: -1 | 0 | 1 | 2;
            data?: Record<string, unknown>;
            device_id?: string;
            insight_id: string;
            update?: 0 | 1;
        }
        • annotation: -1 | 0 | 1 | 2

          Annotation of the prediction: 1 to accept the prediction, 0 to refuse it, and -1 for skip, 2 to accept and add data

        • Optionaldata?: Record<string, unknown>

          Additional data provided by the user as key-value pairs (required when annotation=2)

        • Optionaldevice_id?: string

          Device identifier for tracking anonymous votes

        • insight_id: string

          Format: uuid

          ID of the insight

          3cd5aecd-edcc-4237-87d0-6595fc4e53c9
          
        • Optionalupdate?: 0 | 1

          Send the update to Openfoodfacts if update=1, don't send the update otherwise. This parameter is useful if the update is performed client-side

          1
          @enum {integer}

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path?: never;
                      query?: never;
                  };
                  requestBody: {
                      content: {
                          "application/x-www-form-urlencoded": {
                              annotation: -1
                              | 0
                              | 1
                              | 2;
                              data?: Record<string, unknown>;
                              device_id?: string;
                              insight_id: string;
                              update?: 0 | 1;
                          };
                      };
                  };
                  responses: {
                      "200": {
                          content: {
                              "application/json": {
                                  description?: string;
                                  status?: string;
                                  status_code?: number;
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                      "400": { content?: never; headers: { [name: string]: unknown } };
                      "404": { content?: never; headers: { [name: string]: unknown } };
                  };
              },
              {
                  body: {
                      annotation: -1
                      | 0
                      | 1
                      | 2;
                      data?: Record<string, unknown>;
                      device_id?: string;
                      insight_id: string;
                      update?: 0 | 1;
                  };
                  bodySerializer: (params: Record<string, FormBodyValue>) => string;
                  headers: { "Content-Type": string };
              },
              `${string}/${string}`,
          >,
      >

    • Parameters

      • id: string

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path: { insight_id: string };
                      query?: never;
                  };
                  requestBody?: never;
                  responses: {
                      "200": {
                          content: {
                              "application/json": {
                                  barcode: number;
                                  countries: string[];
                                  id: string;
                                  type: string;
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              { params: { path: { insight_id: string } } },
              `${string}/${string}`,
          >,
      >

    • Fetches insights based on the provided query.

      Parameters

      • query: {
            annotated?: boolean;
            annotation?: number;
            barcode?: number;
            brands?: string;
            campaigns?: string;
            count?: number;
            countries?: string;
            insight_types?: string;
            lc?: string;
            order_by?: "random" | "popularity";
            page?: number;
            predictor?: string;
            server_type?: "off" | "obf" | "opff" | "opf" | "off_pro";
            value_tag?: string;
        }

        The query object containing parameters for fetching insights.

        • Optionalannotated?: boolean

          Filter by annotation status of the insight. A true value (1, true) means we only return annotated insights, a false value (0, false) only non-annotated insights. If the parameter is not provided, both annotated and non-annotated insights are returned.

        • Optionalannotation?: number

          Filter by annotation value of the insight. If not provided, all insights are returned. This works in conjunction with the annotated parameter.

        • Optionalbarcode?: number

          Filter by barcode value

        • Optionalbrands?: string

          Comma-separated list, filter by brands

        • Optionalcampaigns?: string

          Filter by annotation campaigns (the insight must have all the campaigns) An annotation campaign allows to only retrieve questions or insights based on arbitrary criteria defined during insight import.

        • Optionalcount?: number

          The number of items to return

        • Optionalcountries?: string

          Comma separated list, filter by country value (2-letter code)

          uk
          
        • Optionalinsight_types?: string

          Comma-separated list, filter by insight types

        • Optionallc?: string

          Comma-separated list of language codes to filter insights by language

        • Optionalorder_by?: "random" | "popularity"

          How to order by insight results. By default, results are not ordered. Possible values are: - random: insights are ordered randomly - popularity: insights are returned by decreasing popularity, using the number of scans as proxy

        • Optionalpage?: number

          Page index to return (starting at 1)

        • Optionalpredictor?: string

          Filter by predictor value A predictor refers to the model/method that was used to generate the prediction.

        • Optionalserver_type?: "off" | "obf" | "opff" | "opf" | "off_pro"

          The server type (=project) to use, such as 'off' (Open Food Facts), 'obf' (Open Beauty Facts),...

        • Optionalvalue_tag?: string

          Filter by value tag, i.e the value that is going to be sent to Product Opener

          en:organic
          

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path?: never;
                      query?: {
                          annotated?: boolean;
                          annotation?: number;
                          barcode?: number;
                          brands?: string;
                          campaigns?: string;
                          count?: number;
                          countries?: string;
                          insight_types?: string;
                          lc?: string;
                          order_by?: "random"
                          | "popularity";
                          page?: number;
                          predictor?: string;
                          server_type?: "off" | "obf" | "opff" | "opf" | "off_pro";
                          value_tag?: string;
                      };
                  };
                  requestBody?: never;
                  responses: {
                      "200": {
                          content: {
                              "application/json": {
                                  count?: number;
                                  insights?: {
                                      barcode: number;
                                      countries: string[];
                                      id: string;
                                      type: string;
                                  }[];
                                  status?: "found"
                                  | "no_insights";
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              {
                  params: {
                      query: {
                          annotated?: boolean;
                          annotation?: number;
                          barcode?: number;
                          brands?: string;
                          campaigns?: string;
                          count?: number;
                          countries?: string;
                          insight_types?: string;
                          lc?: string;
                          order_by?: "random"
                          | "popularity";
                          page?: number;
                          predictor?: string;
                          server_type?: "off" | "obf" | "opff" | "opf" | "off_pro";
                          value_tag?: string;
                      };
                  };
              },
              `${string}/${string}`,
          >,
      >

      A promise that resolves to the data from the insights endpoint

    • Parameters

      • logoId: string

      Returns Promise<any>

    • Parameters

      • code: number
      • Optionalquery: {
            count?: number;
            insight_types?: string;
            lang?: string;
            server_type?: "off" | "obf" | "opff" | "opf" | "off_pro";
        }
        • Optionalcount?: number

          The number of questions to return

        • Optionalinsight_types?: string

          Comma-separated list, filter by insight types

        • Optionallang?: string

          The language of the question/value

        • Optionalserver_type?: "off" | "obf" | "opff" | "opf" | "off_pro"

          The server type (=project) to use, such as 'off' (Open Food Facts), 'obf' (Open Beauty Facts),...

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path: { barcode: number };
                      query?: {
                          count?: number;
                          insight_types?: string;
                          lang?: string;
                          server_type?: "off" | "obf" | "opff" | "opf" | "off_pro";
                      };
                  };
                  requestBody?: never;
                  responses: {
                      "200": {
                          content: {
                              "application/json": {
                                  questions?: Record<string, unknown>[];
                                  status?: "no_questions" | "found";
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              {
                  params: {
                      path: { barcode: number };
                      query: {
                          count?: number;
                          insight_types?: string;
                          lang?: string;
                          server_type?: "off" | "obf" | "opff" | "opf" | "off_pro";
                      };
                  };
              },
              `${string}/${string}`,
          >,
      >