# `faker.providers.barcode`

class faker.providers.barcode.Provider(generator: Any)

  Bases: `BaseProvider`

  Implement default barcode provider for Faker.

  Sources:

  - https://gs1.org/standards/id-keys/company-prefix

  ean(length: int = 13, prefixes: Tuple[int | str | Tuple[int | str, ...], ...] = ()) → str

    Generate an EAN barcode of the specified `length`.

    The value of `length` can only be `8` or `13` (default) which will create an EAN-8 or an EAN-13 barcode respectively.

    If a value for `prefixes` is specified, the result will begin with one of the sequences in `prefixes`.

    Examples:

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean(length=13)
        ...
        '6604876475937'
        '8242194892418'
        '1578156593879'
        '7840801609759'
        '3513933287112'

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean(length=8)
        ...
        '66048763'
        '47593824'
        '42194897'
        '24115780'
        '15659385'

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean(prefixes=('00', ))
        ...
        '0004876475931'
        '0019489241156'
        '0056593877840'
        '0016097535134'
        '0087115871480'

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean(prefixes=('45', '49'))
        ...
        '4504876475932'
        '4919489241155'
        '4556593877841'
        '4516097535135'
        '4987115871489'

  ean13(prefixes: Tuple[int | str | Tuple[int | str, ...], ...] = ()) → str

    Generate an EAN-13 barcode.

    This method uses `ean()` under the hood with the `length` argument explicitly set to `13`.

    If a value for `prefixes` is specified, the result will begin with one of the sequences in `prefixes`.

    Note

    Codes starting with a leading zero are treated specially in some barcode readers. For more information on compatibility with UPC-A codes, see `EnUsBarcodeProvider.ean13()`.

    Examples:

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean13()
        ...
        '6604876475937'
        '8242194892418'
        '1578156593879'
        '7840801609759'
        '3513933287112'

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean13(prefixes=('00', ))
        ...
        '0004876475931'
        '0019489241156'
        '0056593877840'
        '0016097535134'
        '0087115871480'

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean13(prefixes=('45', '49'))
        ...
        '4504876475932'
        '4919489241155'
        '4556593877841'
        '4516097535135'
        '4987115871489'

  ean8(prefixes: Tuple[int | str | Tuple[int | str, ...], ...] = ()) → str

    Generate an EAN-8 barcode.

    This method uses `ean()` under the hood with the `length` argument explicitly set to `8`.

    If a value for `prefixes` is specified, the result will begin with one of the sequences in `prefixes`.

    Examples:

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean8()
        ...
        '66048763'
        '47593824'
        '42194897'
        '24115780'
        '15659385'

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean8(prefixes=('00', ))
        ...
        '00048767'
        '00938242'
        '00489249'
        '00781565'
        '00877848'

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.ean8(prefixes=('45', '49'))
        ...
        '49048766'
        '45938245'
        '45489242'
        '49781564'
        '45877841'

  localized_ean(length: int = 13) → str

    Generate a localized EAN barcode of the specified `length`.

    The value of `length` can only be `8` or `13` (default) which will create an EAN-8 or an EAN-13 barcode respectively.

    This method uses the standard barcode provider’s `ean()` under the hood with the `prefixes` argument explicitly set to `local_prefixes` of a localized barcode provider implementation.

    Examples:

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.localized_ean()
        ...
        '0804876475937'
        '1321948924111'
        '1381565938779'
        '1108016097539'
        '0839332871152'

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.localized_ean(length=13)
        ...
        '0804876475937'
        '1321948924111'
        '1381565938779'
        '1108016097539'
        '0839332871152'

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.localized_ean(length=8)
        ...
        '12048762'
        '04593829'
        '04948926'
        '06578152'
        '04387787'

  localized_ean13() → str

    Generate a localized EAN-13 barcode.

    This method uses `localized_ean()` under the hood with the `length` argument explicitly set to `13`.

    Examples:

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.localized_ean13()
        ...
        '0804876475937'
        '1321948924111'
        '1381565938779'
        '1108016097539'
        '0839332871152'

  localized_ean8() → str

    Generate a localized EAN-8 barcode.

    This method uses `localized_ean()` under the hood with the `length` argument explicitly set to `8`.

    Examples:

        >>> Faker.seed(0)
        >>> for _ in range(5):
        ...     fake.localized_ean8()
        ...
        '12048762'
        '04593829'
        '04948926'
        '06578152'
        '04387787'