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

    Class NutriPatrol

    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 NutriPatrol

    Properties

    client: Client<paths>

    Methods

    • Create a flag in the NutriPatrol API.

      Parameters

      • flag: {
            barcode?: string;
            comment?: string;
            confidence?: number;
            created_at?: string;
            flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
            image_id?: string;
            reason?: string;
            source: "mobile" | "web" | "robotoff";
            type: "search" | "product" | "image";
            url: string;
            user_id: string;
        }

        Data for the flag to create.

        • Optionalbarcode?: string

          Barcode

          Barcode of the product, if the flag is about a product or a product image. In case of a search issue, this field is null.

        • Optionalcomment?: string

          Comment

          Comment provided by the user during flagging. This is a free text field.

        • Optionalconfidence?: number

          Confidence

          Confidence score of the model that generated the flag, this field should only be provided by Robotoff.

        • Optionalcreated_at?: string

          Created At Format: date-time

          Creation datetime of the flag

        • flavor: "off" | "obf" | "opff" | "opf" | "off-pro"

          Flavor (project) associated with the ticket

        • Optionalimage_id?: string

          Image Id

          ID of the flagged image

        • Optionalreason?: string

          Reason

          Reason for flagging provided by the user. The field is optional.

        • source: "mobile" | "web" | "robotoff"

          Source of the flag. It can be a user from the mobile app, the web or a flag generated automatically by robotoff.

        • type: "search" | "product" | "image"

          Type of the issue

        • url: string

          Url

          URL of the product or of the flagged image

        • user_id: string

          User Id

          Open Food Facts User ID of the flagger

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path?: never;
                      query?: never;
                  };
                  requestBody: {
                      content: {
                          "application/json": {
                              barcode?: string;
                              comment?: string;
                              confidence?: number;
                              created_at?: string;
                              flavor: "off"
                              | "obf"
                              | "opff"
                              | "opf"
                              | "off-pro";
                              image_id?: string;
                              reason?: string;
                              source: "mobile" | "web" | "robotoff";
                              type: "search" | "product" | "image";
                              url: string;
                              user_id: string;
                          };
                      };
                  };
                  responses: {
                      "200": {
                          content: {
                              "application/json": {
                                  barcode?: string;
                                  comment?: string;
                                  confidence?: number;
                                  created_at?: string;
                                  device_id: string;
                                  flavor: "off"
                                  | "obf"
                                  | "opff"
                                  | "opf"
                                  | "off-pro";
                                  id: number;
                                  image_id?: string;
                                  reason?: string;
                                  source: "mobile" | "web" | "robotoff";
                                  ticket_id: number;
                                  type: "search" | "product" | "image";
                                  url: string;
                                  user_id: string;
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                      "422": {
                          content: {
                              "application/json": {
                                  detail?: { loc: ((...) | (...))[]; msg: string; type: string }[];
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              {
                  body: {
                      barcode?: string;
                      comment?: string;
                      confidence?: number;
                      created_at?: string;
                      flavor: "off"
                      | "obf"
                      | "opff"
                      | "opf"
                      | "off-pro";
                      image_id?: string;
                      reason?: string;
                      source: "mobile" | "web" | "robotoff";
                      type: "search" | "product" | "image";
                      url: string;
                      user_id: string;
                  };
              },
              `${string}/${string}`,
          >,
      >

    • Get the status of the NutriPatrol API.

      If the returned status.data is undefined, it indicates that the API is down or unreachable.

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path?: never;
                      query?: never;
                  };
                  requestBody?: never;
                  responses: {
                      "200": {
                          content: { "application/json": { status: string } };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              FetchOptions<
                  {
                      parameters: {
                          cookie?: never;
                          header?: never;
                          path?: never;
                          query?: never;
                      };
                      requestBody?: never;
                      responses: {
                          "200": {
                              content: { "application/json": { status: string } };
                              headers: { [name: string]: unknown };
                          };
                      };
                  },
              >,
              `${string}/${string}`,
          >,
      >

      const { data } = await nutripatrol.getApiStatus();
      if (!data) throw new Error("API is down or unreachable");
    • Retrieves a specific flag by its ID from the NutriPatrol API.

      Parameters

      • flagId: number

        The ID of the flag to fetch.

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path: { flag_id: number };
                      query?: never;
                  };
                  requestBody?: never;
                  responses: {
                      "200": {
                          content: {
                              "application/json": {
                                  barcode?: string;
                                  comment?: string;
                                  confidence?: number;
                                  created_at?: string;
                                  device_id: string;
                                  flavor: "off"
                                  | "obf"
                                  | "opff"
                                  | "opf"
                                  | "off-pro";
                                  id: number;
                                  image_id?: string;
                                  reason?: string;
                                  source: "mobile" | "web" | "robotoff";
                                  ticket_id: number;
                                  type: "search" | "product" | "image";
                                  url: string;
                                  user_id: string;
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                      "422": {
                          content: {
                              "application/json": {
                                  detail?: { loc: ((...) | (...))[]; msg: string; type: string }[];
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              { params: { path: { flag_id: number } } },
              `${string}/${string}`,
          >,
      >

      A promise that resolves with the flag data if found or error.

      const { data, error } = await nutripatrol.getFlagById(123);
      
    • List all flags.

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path?: never;
                      query?: never;
                  };
                  requestBody?: never;
                  responses: {
                      "200": {
                          content: {
                              "application/json": {
                                  flags: {
                                      barcode?: string;
                                      comment?: string;
                                      confidence?: number;
                                      created_at?: string;
                                      device_id: string;
                                      flavor: "off"
                                      | "obf"
                                      | "opff"
                                      | "opf"
                                      | "off-pro";
                                      id: number;
                                      image_id?: string;
                                      reason?: string;
                                      source: "mobile" | "web" | "robotoff";
                                      ticket_id: number;
                                      type: "search" | "product" | "image";
                                      url: string;
                                      user_id: string;
                                  }[];
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              FetchOptions<
                  {
                      parameters: {
                          cookie?: never;
                          header?: never;
                          path?: never;
                          query?: never;
                      };
                      requestBody?: never;
                      responses: {
                          "200": {
                              content: {
                                  "application/json": {
                                      flags: {
                                          barcode?: string;
                                          comment?: string;
                                          confidence?: number;
                                          created_at?: string;
                                          device_id: string;
                                          flavor: (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...);
                                          id: number;
                                          image_id?: string;
                                          reason?: string;
                                          source: (...) | (...) | (...);
                                          ticket_id: number;
                                          type: (...) | (...) | (...);
                                          url: string;
                                          user_id: string;
                                      }[];
                                  };
                              };
                              headers: { [name: string]: unknown };
                          };
                      };
                  },
              >,
              `${string}/${string}`,
          >,
      >

      • A promise that resolves with the list of flag data or error.
      const { data, error } = await nutripatrol.getFlags();
      if (error) console.error("Error fetching flags:", error);
      else console.log("Flags:", data);
    • Get flags by ticket batch.

      Parameters

      • ticketIds: number[]

        Ids of ticket to get flags from.

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path?: never;
                      query?: never;
                  };
                  requestBody: {
                      content: { "application/json": { ticket_ids: number[] } };
                  };
                  responses: {
                      "200": {
                          content: { "application/json": unknown };
                          headers: { [name: string]: unknown };
                      };
                      "422": {
                          content: {
                              "application/json": {
                                  detail?: { loc: ((...) | (...))[]; msg: string; type: string }[];
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              { body: { ticket_ids: number[] } },
              `${string}/${string}`,
          >,
      >

      A promise that resolves with the flags data or error.

      const { data, error } = await nutripatrol.getFlagsByTicketBatch([123, 456]);
      
    • Retrieves a specific ticket by its ID from the NutriPatrol API.

      Parameters

      • ticketId: number

        The ID of the ticket to fetch.

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path: { ticket_id: number };
                      query?: never;
                  };
                  requestBody?: never;
                  responses: {
                      "200": {
                          content: { "application/json": unknown };
                          headers: { [name: string]: unknown };
                      };
                      "422": {
                          content: {
                              "application/json": {
                                  detail?: { loc: ((...) | (...))[]; msg: string; type: string }[];
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              { params: { path: { ticket_id: number } } },
              `${string}/${string}`,
          >,
      >

      const { data, error } = await nutripatrol.getTicketById(123);
      if (!data) console.error("Error fetching ticket:", error);
    • List all tickets.

      Parameters

      • query: {
            page?: number;
            page_size?: number;
            reason?: ("other" | "inappropriate" | "human" | "beauty")[];
            status: "closed" | "open";
            type?: string;
        }

        Parameters to filter the tickets.

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path?: never;
                      query?: {
                          page?: number;
                          page_size?: number;
                          reason?: ("other" | "inappropriate" | "human" | "beauty")[];
                          status?: "closed" | "open";
                          type_?: "search" | "product" | "image";
                      };
                  };
                  requestBody?: never;
                  responses: {
                      "200": {
                          content: {
                              "application/json": {
                                  max_page: number;
                                  tickets: {
                                      barcode?: string;
                                      created_at?: string;
                                      flavor: "off"
                                      | "obf"
                                      | "opff"
                                      | "opf"
                                      | "off-pro";
                                      id: number;
                                      image_id?: string;
                                      status: "closed" | "open";
                                      type: "search" | "product" | "image";
                                      url: string;
                                  }[];
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                      "422": {
                          content: {
                              "application/json": {
                                  detail?: { loc: ((...) | (...))[]; msg: string; type: string }[];
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              {
                  params: {
                      query: {
                          page?: number;
                          page_size?: number;
                          reason?: ("other" | "inappropriate" | "human" | "beauty")[];
                          status: "closed" | "open";
                          type?: string;
                      };
                  };
              },
              `${string}/${string}`,
          >,
      >

      A promise that resolves with the list of tickets or error.

      const { data, error } = await nutripatrol.getTickets({
      status: "open",
      type: "spam",
      reason: ["inappropriate", "human"],
      page: 1,
      page_size: 20,
      });
    • Update a ticket status in the NutriPatrol API.

      Parameters

      • ticketId: number

        The ID of the ticket to update.

      • status: "closed" | "open"

        The new status of the ticket.

      Returns Promise<
          FetchResponse<
              {
                  parameters: {
                      cookie?: never;
                      header?: never;
                      path: { ticket_id: number };
                      query: { status: "closed" | "open" };
                  };
                  requestBody?: never;
                  responses: {
                      "200": {
                          content: {
                              "application/json": {
                                  barcode?: string;
                                  created_at?: string;
                                  flavor: "off"
                                  | "obf"
                                  | "opff"
                                  | "opf"
                                  | "off-pro";
                                  id: number;
                                  image_id?: string;
                                  status: "closed" | "open";
                                  type: "search" | "product" | "image";
                                  url: string;
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                      "422": {
                          content: {
                              "application/json": {
                                  detail?: { loc: ((...) | (...))[]; msg: string; type: string }[];
                              };
                          };
                          headers: { [name: string]: unknown };
                      };
                  };
              },
              {
                  params: {
                      path: { ticket_id: number };
                      query: { status: "closed" | "open" };
                  };
              },
              `${string}/${string}`,
          >,
      >

      const { data, error } = await nutripatrol.updateTicketStatus(123, "closed");
      if (!data) console.error("Error updating ticket status:", error);