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>

    • authToken: string

    Returns Folksonomy

Properties

raw: Client<paths, `${string}/${string}`>

Methods

  • Update a product tag (or add it if it does not exist)

    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: 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

  • Get a list of existing tags for a product

    Parameters

    • barcode: string

    Returns Promise<
        FetchResponse<
            {
                parameters: { path: { product: string }; query?: { owner?: unknown } };
                responses: {
                    "200": {
                        content: {
                            "application/json": {
                                comment?: string;
                                editor?: string;
                                k: string;
                                last_edit?: string;
                                owner?: string;
                                product: string;
                                v: string;
                                version?: number;
                            }[];
                        };
                    };
                    "422": {
                        content: {
                            "application/json": {
                                detail?: { loc: (...)[]; msg: string; type: string }[];
                            };
                        };
                    };
                };
            },
            { params: { path: { product: string } } },
            `${string}/${string}`,
        >,
    >

  • 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;
        }[],
    >

  • 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

  • Parameters

    • tag: {
          comment?: string;
          editor?: string;
          k: string;
          last_edit?: string;
          owner?: string;
          product: string;
          v: string;
          version?: number;
      }
      • 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>

  • 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 }
      • 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<
        FetchResponse<
            {
                parameters: {
                    path: { k: string; product: string };
                    query: { owner?: unknown; version: number };
                };
                responses: {
                    "200": { content: { "application/json": unknown } };
                    "422": {
                        content: {
                            "application/json": {
                                detail?: { loc: (...)[]; msg: string; type: string }[];
                            };
                        };
                    };
                };
            },
            {
                params: {
                    path: { k: string; product: string };
                    query: { version: number };
                };
            },
            `${string}/${string}`,
        >,
    >

    if the tag was deleted