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

    Class Folksonomy

    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>

      • Optionaloptions: { authToken?: string; baseUrl?: string }

      Returns Folksonomy

    Properties

    raw: Client<paths>

    Methods

    • Add a product tag, returns error if the tag already exists

      Parameters

      • tag: {
            comment?: string;
            editor?: string;
            k: string;
            last_edit?: string;
            owner?: string;
            product: string;
            v: string;
            version?: number;
        }

        Tag to add or update with the following fields:

        • k: key
        • v: value
        • product: barcode
        • version: if passed it should be equal to 1
        • owner: user_id of the owner of the tag (empty for public tags)
        • Optionalcomment?: string

          Comment

          
          
        • Optionaleditor?: string

          Editor

        • k: string

          K

        • Optionallast_edit?: string

          Last Edit Format: date-time

        • Optionalowner?: string

          Owner

          
          
        • product: string

          Product

        • v: string

          V

        • Optionalversion?: number

          Version

          1
          

      Returns Promise<boolean>

      if the tag was added or updated

    • Get the list of products that have a key or key=value if value is provided

      Parameters

      • key: string
      • Optionalvalue: string

      Returns Promise<
          {
              comment?: string;
              editor?: string;
              k: string;
              last_edit?: string;
              owner?: string;
              product: string;
              v: string;
              version?: number;
          }[],
      >

    • Get a list of existing tags for a product

      Parameters

      • barcode: string

      Returns Promise<
          {
              comment?: string;
              editor?: string;
              k: string;
              last_edit?: string;
              owner?: string;
              product: string;
              v: string;
              version?: number;
          }[],
      >

    • Authentication: provide user/password and get a bearer token in return

      Parameters

      • username: string

        Open Food Facts user_id (not email)

      • password: string

        user password

      Returns Promise<
          | { token: { access_token: string; token_type: string } }
          | { error: ApiError },
      >

      the bearer token, to be used in later requests with usual "Authorization: bearer token" headers

    • Update a product tag, returns error if the tag does not exist

      Parameters

      • tag: {
            comment?: string;
            editor?: string;
            k: string;
            last_edit?: string;
            owner?: string;
            product: string;
            v: string;
            version?: number;
        }

        Tag to update with the following fields:

        • k: key
        • v: value
        • product: barcode
        • version: version of the tag (must be equal to previous version + 1)
        • owner: user_id of the owner of the tag (empty for public tags)
        • Optionalcomment?: string

          Comment

          
          
        • Optionaleditor?: string

          Editor

        • k: string

          K

        • Optionallast_edit?: string

          Last Edit Format: date-time

        • Optionalowner?: string

          Owner

          
          
        • product: string

          Product

        • v: string

          V

        • Optionalversion?: number

          Version

          1
          

      Returns Promise<boolean>

      if the tag was added or updated

    • Delete a product tag

      Parameters

      • tag: {
            comment?: string;
            editor?: string;
            k: string;
            last_edit?: string;
            owner?: string;
            product: string;
            v: string;
            version?: number;
        } & { version: number }

        Tag to delete with the following fields:

        • k: key
        • v: value
        • product: barcode
        • version: version of the tag [required]
        • owner: user_id of the owner of the tag (empty for public tags)
        • Optionalcomment?: string

          Comment

          
          
        • Optionaleditor?: string

          Editor

        • k: string

          K

        • Optionallast_edit?: string

          Last Edit Format: date-time

        • Optionalowner?: string

          Owner

          
          
        • product: string

          Product

        • v: string

          V

        • Optionalversion?: number

          Version

          1
          
        • version: number

      Returns Promise<boolean>

      if the tag was deleted