clabe
raw JSON → 2.1.10 verified Mon Apr 27 auth: no python
Validate and generate the control digit of a CLABE (Clave Bancaria Estandarizada) in Mexico. Current version: 2.1.10, requires Python >=3.8. Active development with monthly releases.
pip install clabe Common errors
error ModuleNotFoundError: No module named 'clabe' ↓
cause Library not installed or installed under different name.
fix
Run
pip install clabe (not pip install CLABE). error AttributeError: module 'clabe' has no attribute 'CLABE' ↓
cause Old import pattern using `from clabe import CLABE`; API changed in v2.
fix
Use
from clabe import clabe and then call clabe('...'). error TypeError: 'str' object is not callable ↓
cause Accidentally named a variable `clabe` before importing.
fix
Do not name your variable
clabe. Use a different variable name like my_clabe. Warnings
breaking In version 2.0.0, the API was rewritten. The old `CLABE` class is replaced by a simple function and module-level methods. ↓
fix Upgrade and use `from clabe import clabe` then call `clabe('...')` instead of `CLABE('...')`.
gotcha The CLABE string must be exactly 18 digits. Passing digits with spaces or formatting will cause validation errors. ↓
fix Strip non-digit characters: `clabe('0321 8000 0118 3597 19')` fails; use `clabe('032180000118359719')`.
gotcha The `clabe.get_banks()` method returns a list of dicts, but the dict keys are not guaranteed to be consistent across versions. ↓
fix Always access dict keys safely with `.get()`, e.g., `bank.get('name')`.
Imports
- clabe
from clabe import clabe - BankConfigRequest
from clabe import BankConfigRequest
Quickstart
from clabe import clabe
# Validate a CLABE
result = clabe('032180000118359719')
print(result.valid) # True or False
# Generate the control digit
clabe_number = '03218000011835971'
digit = clabe.generate_check_digit(clabe_number)
print(digit) # e.g., 9
# Get bank info
banks = clabe.get_banks()
print(banks[:2])