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>

    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;
                };
            },
            `${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<
        | undefined
        | SuccessResponse<
            | {
                "200": {
                    content: {
                        "application/json": {
                            questions?: Record<(...), (...)>[];
                            status?: "no_questions" | "found";
                        };
                    };
                };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            count?: number;
                            questions?: Record<(...), (...)>[];
                            status?: "no_questions" | "found";
                        };
                    };
                };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            count?: number;
                            questions?: Record<(...), (...)>[];
                            status?: "no_questions" | "found";
                        };
                    };
                };
            }
            | { "200": { content: {} } }
            | {
                "200": {
                    content: {
                        "application/json": {
                            count: number;
                            questions: (string | number)[];
                            status: "no_questions" | "found";
                        };
                    };
                };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            count?: number;
                            predictions?: Record<(...), (...)>[];
                            status?: "found" | "no_predictions";
                        };
                    };
                };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            insights?: { barcode: ...; countries: ...; id: ...; type: ... }[];
                        };
                    };
                };
            }
            | { "200": { content: {} } }
            | {
                "200": {
                    content: {
                        "application/json": {
                            count?: number;
                            insights?: { barcode: ...; countries: ...; id: ...; type: ... }[];
                            status?: "found" | "no_insights";
                        };
                    };
                };
            }
            | { "200": { content: {} } }
            | {
                "200": { content: { "text/csv": string } };
                "204": { content: never };
                "400": { content: never };
            }
            | { "200": { content: { "image/jpeg": string } } }
            | {
                "200": {
                    content: {
                        "application/json": {
                            count?: number;
                            image_predictions?: Record<(...), (...)>[];
                            status?: "found" | "no_image_predictions";
                        };
                    };
                };
            }
            | {
                "200": {
                    content: { "application/json": { count: number; logos: unknown[] } };
                };
            }
            | {
                "200": {
                    content: { "application/json": { count: number; logos: unknown[] } };
                };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            count: number;
                            query_logo_id: number;
                            results: { distance: number; logo_id: number }[];
                        };
                    };
                };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            count: number;
                            query_logo_id: number;
                            results: { distance: number; logo_id: number }[];
                        };
                    };
                };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            errors?: { error?: ...; error_description?: ... }[];
                            image_ids: number[];
                            predictions: {
                                nutrients: Record<string, never>;
                                predictor: string;
                                predictor_version: string;
                                source_image: string;
                            };
                        };
                    };
                };
                "400": { content: never };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            predictions: {
                                automatic_processing?: (...)
                                | (...)
                                | (...);
                                barcode?: (...) | (...);
                                confidence?: (...) | (...);
                                data?: (...) | (...);
                                id?: (...) | (...);
                                predictor?: (...) | (...);
                                predictor_version?: (...) | (...);
                                server_type?: (...) | (...) | (...) | (...) | (...) | (...);
                                source_image?: (...) | (...);
                                timestamp?: (...) | (...);
                                type?: (...) | (...);
                                value?: (...) | (...);
                                value_tag?: (...) | (...);
                            }[];
                        };
                    };
                };
                "400": { content: never };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            predictions?: { confidence?: ...; lang?: ... }[];
                        };
                    };
                };
                "400": { content: never };
            }
            | {
                "200": {
                    content: {
                        "application/json": {
                            counts?: { count?: ...; lang?: ... }[];
                            image_ids?: number[];
                            percent?: { lang?: ...; percent?: ... }[];
                        };
                    };
                };
                "400": { content: never };
            },
            `${string}/${string}`,
        >,
    >

  • Parameters

    • code: number

    Returns Promise<
        | undefined
        | {
            questions?: Record<string, never>[];
            status?: "no_questions" | "found";
        },
    >