Skip to main content

barkod

GTIN parsing, canonicalisation, match keys and GS1 classification. Written in Rust; this is the Python binding.

pip install barkod
import barkod

barkod.store_form("7350053850019")   # '07350053850019'  — padded, check digit kept
barkod.store_form("lek")             # 'lek'             — untouched, never blanked
barkod.key("7350053850019")          # GtinKey('07350053850010')
barkod.key("073905259077450")        # None              — 15 digits is not a GTIN

p = barkod.parse("370245100000000123")
p.is_gtin                            # False
p.reason                             # 'too_long'
p.message                            # 'More than 14 digits — not a GTIN'
p.raw                                # '370245100000000123' — always kept

The domain

Every function agrees that a GTIN is 8 to 14 digits and differs only on what it does inside that range. Outside it, store_form hands the input back untouched and key returns None. A lossy transformation is not a licence to be more permissive about what counts as a GTIN.

The key is not a GTIN

key() returns a GtinKey, not a str. It has no __str__, so printing one gives GtinKey('07390525907740') rather than a bare number — a key that leaks into an export is visibly wrong instead of a plausible fabricated identifier. Roughly nine in ten keys end in a check digit no product has.

key = barkod.key("7390525907745")
f"{key}"            # "GtinKey('07390525907740')"
key.as_key_str()    # '07390525907740'  — say it out loud

Columns

store_form_many, key_strings and parse_many take a whole column and release the GIL for the work. They accept whatever the column actually holds — str, int, float or None.

import polars as pl

df = df.with_columns(
    pl.Series("gtin_key", barkod.key_strings(df["gtin"].to_list()))
)

key_strings is named for what it does. It is the one place the type distinction is deliberately dropped, because a dataframe column needs strings, so the call site has to say so.

Classify, never reject

An invalid check digit does not mean "not a GTIN". Variable-weight in-store codes and internal PLUs are live products that fail GS1 Mod-10 by design.

g = barkod.parse("02011030000000").gtin
g.check_digit_is_valid        # False
g.allocation                  # 'restricted_circulation_region'
g.measure_field_looks_zeroed  # True  — a named guess, not a verdict

Full documentation: https://github.com/mommo-codes/barkod

MIT licensed.

Metadata

Release files for barkod 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for barkod 0.1.2
File Actions
barkod-0.1.2-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for barkod-0.1.2-cp38-abi3-win_amd64.whl
barkod-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for barkod-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
barkod-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for barkod-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
barkod-0.1.2-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for barkod-0.1.2-cp38-abi3-macosx_11_0_arm64.whl

Total release size: 1.0 MB

Release files / barkod-0.1.2-cp38-abi3-win_amd64.whl

Download URL barkod-0.1.2-cp38-abi3-win_amd64.whl
Size 163.1 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e9ba8e443e146b5a31f3cd4a3a06db52db521c4f5055beedc0ee835c52bf0302
BLAKE2b-256 checksum
How to use checksums
830f011f98dc1cbe1c01b48eb56ccffae4157baae5a64183cde24da1a15bafe3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / barkod-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL barkod-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 306.3 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
0f64612e952f6869c613606d47a9ecbfb42a74f0f6ce189b9cfd71e33b59f0e0
BLAKE2b-256 checksum
How to use checksums
0d991a49b9f30fac9141797d2fec60cccece57671c7cad6bb4beb096aaea7971
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / barkod-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL barkod-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 302.3 kB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
abbe310631843db0fdcdfbe608d68b30dbf52b64f857a51f56589bc9cbaebb66
BLAKE2b-256 checksum
How to use checksums
f1149411c3ecb5db6945043fae861bd4c91df43b0b8a4b8d486d46944cf15833
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / barkod-0.1.2-cp38-abi3-macosx_11_0_arm64.whl

Download URL barkod-0.1.2-cp38-abi3-macosx_11_0_arm64.whl
Size 267.9 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1b95db11a42a45e8d2fd3a29c1bb0a9c23753f672615c05bfe3c4a1d60f5aa28
BLAKE2b-256 checksum
How to use checksums
005aa733afbcc320607fcf348d5f4b32e8c69db76aa438e88dfd77bc6addf407
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Security for barkod 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for barkod-0.1.2-cp38-abi3-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page