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

Uploaded Python 3

File details

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

File metadata

  • Download URL: jancodegen-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 bf2e0dabaca0bb2e267645766122ca545b8e412925084a158b3cd1eaff746fa2
MD5 5bb05dc7191fcd701a361616931c07f1
BLAKE2b-256 d52d48bde676195c83ad289ed16b62782da9ce98a2e528d41bf2fb7c7ad3e407

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jancodegen-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 61651c47f9a7d03d1edc5f7d71e5f8d7e15ff333ad4e5c1b5a99d41e7a56e5f0
MD5 ad13bfb708e0b21100f027b5ae88ed82
BLAKE2b-256 5c1203bbd38e4082e7f5caabf709efa988c22431d3d3d7d931e5183351bae7d0

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