@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?: null | Record<string, never>;
            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?: null | Record<string, never>

          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?: undefined;
                      header?: undefined;
                      path?: undefined;
                      query?: undefined;
                  };
                  requestBody: {
                      content: {
                          "application/x-www-form-urlencoded": {
                              annotation: -1
                              | 0
                              | 1
                              | 2;
                              data?: null | Record<string, never>;
                              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?: undefined; headers: { [name: string]: unknown } };
                      "404": { content?: undefined; headers: { [name: string]: unknown } };
                  };
              },
              {
                  body: {
                      annotation: -1
                      | 0
                      | 1
                      | 2;
                      data?: null | Record<string, never>;
                      device_id?: string;
                      insight_id: string;
                      update?: 0 | 1;
                  };
                  bodySerializer: (
                      body: {
                          annotation: -1 | 0 | 1 | 2;
                          data?: null | Record<string, never>;
                          device_id?: string;
                          insight_id: string;
                          update?: 0 | 1;
                      },
                  ) => URLSearchParams;
                  headers: { "Content-Type": string };
              },
              `${string}/${string}`,
          >,
      >

    • Parameters

      • id: string

      Returns Promise<
          | undefined
          | { barcode: number; countries: string[]; id: string; type: string },
      >

    • Fetches insights based on the provided query.

      Parameters

      • query:
            | undefined
            | {
                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.

        • undefined
        • {
              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;
          }
          • 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<
          | undefined
          | {
              count?: number;
              insights?: {
                  barcode: number;
                  countries: string[];
                  id: string;
                  type: string;
              }[];
              status?: "found"
              | "no_insights";
          },
      >

      A promise that resolves to the data from the insights endpoint

    • Parameters

      • logoId: string

      Returns Promise<any>

    • Parameters

      • code: number

      Returns Promise<QuestionsResponse>