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

Uploaded Python 3

File details

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

File metadata

  • Download URL: jancodegen-1.0.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-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6793cf5b8591401f997f7737c3b4865ab316719d65cf43e68e6eb5d461d01ce3
MD5 bcb497fc3f1d7ecfa38b0bdd05a952dd
BLAKE2b-256 3a318d342e261b81ee2a6596a55fa021fb51f2e6ac6d6683760e074298bd0f45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jancodegen-1.0.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-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77a522257b7621da11be86d214a56b61d9e8fbfd8168ae10cfae0afa002a9085
MD5 dfc13ce91d1cd2c6d991d8311cd5d341
BLAKE2b-256 c369d7a279ebcf2fbd5d9e978e459de769a0d45a5dc635c4489400bfd10776a6

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