Skip to main content

Greek AFM (TIN) Validator and Generator

Project description

Greek TIN/AFM Validator and Generator

Linux Build Status

Validate and generate Greek TIN (Tax Identification Number) / AFM (Αριθμός Φορολογικού Μητρώου). Generation function can create valid or invalid numbers including parameters for old format, individuals, legal entities and repet tolerance digits control.

Online demo and presentation


pip install lytrax-afm


Import functions:

from lytrax_afm import validateAFM, \
    generateAFM, \
    generateValidAFM, \

Validate a number:

>>> validate_afm("090000045")

>>> validate_afm("123456789")

Generate a valid number:

>>> generate_valid_afm()

Generate an invalid number:

>>> generate_invalid_afm()



  • afm: str - A string to be check if it's a valid AFM
  • extended_result: bool, optional - Return extended object result if True, single boolean otherwise (default is False)
  • Returns: str or dict (Dictionary with 'valid': boolean and 'error': str ('length' or 'nan' or 'zero' or 'invalid'))


>>> validate_afm("ab1234", extended_result=True)
{'valid': False, 'error': 'length'}


  • force_first_digit: int, optional - If specified, overrides all pre99, legalEntity and individual (default is None)
  • pre99: bool, optional - Για ΑΦΜ πριν από 1/1/1999 (ξεκινάει με 0), (if True, overrides both legal_entity and individual) (default is False)
  • individual: bool, optional - Φυσικά πρόσωπα, (ξεκινάει με 1-4) (default is False)
  • legal_entity: bool, optional - Νομικές οντότητες (ξεκινάει με 7-9) (default is False)
  • repeat_tolerance : int, optional - Number for max repeat tolerance (0 for no repeats, unspecified for no check) (default is None)
  • valid: bool, optional - Generate valid or invalid AFM (default is True)
  • Returns: str - A valid or invalid 9 digit AFM number


>>> generate_afm(force_first_digit=3, repeat_tolerance=1, valid=True)

generate_valid_afm - Same as generate_afm with valid parameter force and override to True

  • Returns: str - A valid 9 digit AFM number


>>> generate_valid_afm(pre99=True)

generate_invalid_afm - Same as generate_afm with valid parameter force and override to False

  • Returns: str - An invalid 9 digit AFM number


>>> generate_invalid_afm(legal_entity=True)


Clone this repository, run test:

git clone && cd afm-python
python -m unittest discover -s './test' -v




MIT License - see the LICENSE file for details

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

lytrax_afm-1.0.1.tar.gz (4.6 kB view hashes)

Uploaded source

Built Distribution

lytrax_afm-1.0.1-py3-none-any.whl (6.2 kB view hashes)

Uploaded py3

Supported by

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