biip

raw JSON →
5.0.0 verified Fri May 01 auth: no python

Biip interprets the data in barcodes. It parses GS1 barcodes (GTIN, GLN, SSCC, etc.), GS1 Application Identifiers, and GS1 Digital Link URIs. Current version 5.0.0, requires Python >=3.10. Active development, releases a few times per year.

pip install biip
error ImportError: cannot import name 'Gtin' from 'biip'
cause Gtin is not exported from the top-level package; it's in biip.gtin.
fix
Use 'from biip.gtin import Gtin'
error AttributeError: 'ParseResult' object has no attribute 'gtin'
cause The parse result does not always contain a gtin; it returns None for non-GTIN barcodes.
fix
Check if result.gtin is not None before using it.
error TypeError: 'Gtin' object does not support item assignment
cause In biip 4.0+, Gtin and other result objects are immutable.
fix
Do not modify Gtin objects; create new ones if needed.
breaking In biip 5.0, Gtin.prefix for GTIN-8 is of type GS18Prefix, not the old type. Accessing prefix attributes may break.
fix Update code to handle GS18Prefix accordingly; see upgrade guide.
breaking In biip 4.0, result objects are now immutable. Trying to set attributes on parse results will raise TypeError.
fix Treat result objects as immutable; use new instances with modifications.
breaking In biip 4.0, biip.parse() no longer raises ParseError when all parsers fail; it raises a different exception or returns None.
fix Check return value for None instead of catching ParseError.
deprecated The old 'gs1_web_uri' module and classes were renamed to 'gs1_digital_link' in 5.0. Old imports will break.
fix Use 'from biip.gs1_digital_link import ...' instead of 'from biip.gs1_web_uri import ...'.
gotcha GS1 message separator char (FNC1) may appear redundantly; biip now ignores multiple separators. Your validation logic may need updating.
fix Ensure your code does not reject redundant separators if that was previous behavior.

Parse a GTIN barcode and a GS1 message with expiry date.

from biip import parse
from biip.gs1 import Gs1Message

# Parse a GTIN barcode
result = parse("04012345123455")
print(result.gtin)  # Gtin(...)

# Parse a GS1 Application Identifier string
message = Gs1Message.parse("(01)04012345123455(17)250101")
print(message.gtin)  # Gtin(...)
print(message.expiration_date)  # datetime.date(2025, 1, 1)