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 Python Versions 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 - see the LICENSE file for details.

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.1.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.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jancodegen-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 75e906f6e2a417d4711ec8fb2fc615f583a323e8541cc02c8bc6af51987b9f1c
MD5 b5aca61937a398a26a9a837cb9d95110
BLAKE2b-256 a9dce38210fd056aafe0ec91476659aa8c18f14382efb87649c0ee385895ad49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jancodegen-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e87358ed3bcff26cd9be7b3e58e138ad101a12f84724b2bea8224289d0f82335
MD5 cf5653a76fe42f279a15630eaae6bd39
BLAKE2b-256 a3ed468e625bb82859493983aad5b46095c7f79e6d445b7b6865b1941635cb62

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