Skip to main content

A Python package for generating random JAN codes and related product identification codes with valid check digits

Project description

JAN Code Generator

PyPI version License: MIT

A Python package for generating random JAN (Japanese Article Number) codes and related product identification codes with valid check digits.

The check digit calculation follows the standard GS1 algorithm as documented on the GS1 Japan website.

Features

  • Generate random GTIN-13 codes
  • Generate random GTIN-8 codes
  • Generate random GTIN-14 codes
  • Generate random UPC-12 codes
  • Generate random SSCC-18 codes
  • Generate random GRAI-14 codes
  • All codes include automatically calculated valid check digits
  • Pure Python implementation with no external dependencies

Installation

Install from PyPI:

pip install jancodegen

Or install from source:

git clone https://github.com/kientt137/jancodegen.git
cd jancodegen
pip install .

Usage

Basic Usage

from jancodegen import jan

# Generate different types of codes
gtin13 = jan.random_gtin_13()    # Returns a 13-digit GTIN-13 code
gtin8 = jan.random_gtin_8()      # Returns an 8-digit GTIN-8 code
gtin14 = jan.random_gtin_14()    # Returns a 14-digit GTIN-14 code
upc12 = jan.random_upc_12()      # Returns a 12-digit UPC-12 code
sscc18 = jan.random_sscc_18()    # Returns an 18-digit SSCC-18 code
grai14 = jan.random_grai_14()    # Returns a 14-digit GRAI-14 code

print(f"GTIN-13: {gtin13}")
print(f"GTIN-8: {gtin8}")

Advanced Usage

import jancodegen.jan as jan

# Generate multiple codes
codes = [jan.random_gtin_13() for _ in range(5)]
for code in codes:
    print(code)

Code Formats

Format Length Description Prefix
GTIN-13 13 digits Global Trade Item Number None
GTIN-8 8 digits Global Trade Item Number (short) None
GTIN-14 14 digits Global Trade Item Number (carton) Starts with '1'
UPC-12 12 digits Universal Product Code None
SSCC-18 18 digits Serial Shipping Container Code Starts with '0'
GRAI-14 14 digits Global Returnable Asset Identifier Starts with '0'

All generated codes include valid check digits calculated using the standard GS1 algorithm.

Requirements

  • Python 3.7 or higher
  • No external dependencies required

Development

Running Tests

pip install pytest
python -m pytest tests/

Building the Package

python setup.py sdist bdist_wheel

License

This project is licensed under the MIT License

Issues

If you find any bugs or have suggestions for improvements, please open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jancodegen-0.1.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jancodegen-0.1.2-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file jancodegen-0.1.2.tar.gz.

File metadata

  • Download URL: jancodegen-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for jancodegen-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8060bf1928fda349bfc6fc87c52db1db23907430056fcea0c1fed10a29edfb9d
MD5 1dd6bbd9126be7d59d6a2923ba3b6592
BLAKE2b-256 3f68538efedc5995485123f6222961f601b45ddc4b24704b0c1a8d3d88003b55

See more details on using hashes here.

File details

Details for the file jancodegen-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: jancodegen-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for jancodegen-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e080c99aedca424f681910c8a45d96e1a6849f21f96fae02015da78359076682
MD5 1abdc4bcf7947cfbd71fdeacd8670752
BLAKE2b-256 cd994d22df504dcf100ced75e8a15e19c06334a07313c6a0ecb877cdebb38686

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page