skillfed

clabe

Validate and generate the control digit of a CLABE in Mexico

clabe v2.1.11 138.3K downloads/30d#11,334 on PyPI42
Permissive license Active released

What it is and what it does

clabe is a Python library for working with CLABE numbers, Mexico's standardized bank account identifiers used in the SPEI payment system. It provides validation, control digit computation, bank name lookup from the bank code, and generation of new valid CLABE numbers. The package integrates directly with pydantic as a custom type, allowing you to use CLABE as a validated field in pydantic models with automatic error reporting for invalid bank codes or malformed numbers.

The library maintains an internal registry of Mexican bank codes and names, with tooling to detect and track changes against the official Banxico participant list. As of version 2.0.0, the package requires pydantic v2 and drops support for earlier versions. You can add or remove banks programmatically, though the maintainers recommend keeping the official bank list synchronized via pull requests rather than runtime modifications.

Use it for:

  • Validate CLABE account numbers in financial transaction forms or APIs before processing payments.
  • Use CLABE as a pydantic field type to automatically validate bank account input in data models.
  • Look up the bank name from a bank code for display or reconciliation purposes.
  • Generate test CLABE numbers for unit tests or sandbox environments.
  • Compute the correct control digit for a partial CLABE to verify or reconstruct account identifiers.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Validates and generates CLABE numbers, Mexico's standard bank account identifier, with built-in bank code lookup and Pydantic integration.

Yes. The package is actively maintained, has no security vulnerabilities, installs with minimal friction (one lightweight dependency), and directly solves a specific problem for anyone working with Mexican banking data. The pydantic integration is particularly valuable if you're already using pydantic for data validation.

Install

clabe on PyPI

pip

pip install clabe

uv

uv add clabe

poetry

poetry add clabe

Installing clabe

Before you install

Low friction: pure Python wheel with only pydantic as a runtime dependency. Actively maintained with a commit as recent as 2026-08-05 and no known vulnerabilities.

License in practice

MIT license (permissive) means you can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions.

Quickstart

pip install clabe

from clabe import Clabe
from pydantic import BaseModel

class Account(BaseModel):
    clabe: Clabe

account = Account(clabe='723010123456789019')
print(account.clabe)

Requires Python 3.8 or higher.

Verify before relying

  • Whether the bank registry is kept in sync with official Banxico SPEI participant list in practice.
  • Performance characteristics when validating large batches of CLABE numbers.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — pydantic
Maintenance actively maintained — 9 days since the last release
Last repo commit
First released
Downloads 138,258/month — #11,334 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: clabe-2.1.11-py3-none-any.whl

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

CLABE validation Mexicobank account number validatorCLABE generator control digitMexican banking identifierPydantic CLABE typeSPEI participant lookup
bankingmexicovalidation

More Utilities packages