@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, never>;
            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, never>

          Additional data provided by the user as key-value pairs

        • insight_id: string

          ID of the insight

        • 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<
              {
                  requestBody: {
                      content: {
                          "application/x-www-form-urlencoded": {
                              annotation: -1
                              | 0
                              | 1
                              | 2;
                              data?: Record<string, never>;
                              insight_id: string;
                              update?: 0 | 1;
                          };
                      };
                  };
                  responses: { "200": { content: {} } };
              },
              {
                  body: {
                      annotation: -1
                      | 0
                      | 1
                      | 2;
                      data?: Record<string, never>;
                      insight_id: string;
                      update?: 0 | 1;
                  };
                  bodySerializer: (
                      body: {
                          annotation: -1 | 0 | 1 | 2;
                          data?: Record<string, never>;
                          insight_id: string;
                          update?: 0 | 1;
                      },
                  ) => URLSearchParams;
                  headers: { "Content-Type": string };
              },
              `${string}/${string}`,
          >,
      >

    • Parameters

      • id: string

      Returns Promise<undefined | {}>

    • Fetches insights based on the provided query.

      Parameters

      • query:
            | undefined
            | {
                annotated?: boolean;
                annotation?: number;
                barcode?: number;
                brands?: string;
                count?: number;
                countries?: string;
                insight_types?: 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.

      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>