Credit Card Identifier - Python Library
Python library for credit card BIN validation and identification.
Supported Card Brands
- American Express (amex)
- Aura
- BaneseCard
- Diners Club
- Discover
- Elo
- Hipercard
- JCB
- Maestro
- Mastercard
- UnionPay
- Visa
Installation
pip install creditcard-identifier
Usage
Module Functions
from creditcard_identifier import find_brand, is_supported
# Identify card brand
brand = find_brand('4012001037141112')
print(brand) # {'name': 'visa', 'regexp_bin': '...', ...}
# Check if card is supported
supported = is_supported('4012001037141112')
print(supported) # True
Using the Validator Class
from creditcard_identifier import CreditCardValidator
validator = CreditCardValidator()
# Identify brand
brand = validator.find_brand('4012001037141112')
print(brand['name']) # 'visa'
# Get detailed brand info
detailed = validator.find_brand('4012001037141112', detailed=True)
print(detailed['scheme']) # 'visa'
print(detailed['matched_pattern']) # {'bin': '^4', 'length': [13, 16, 19], ...}
# Check if supported
supported = validator.is_supported('4012001037141112')
print(supported) # True
# Validate CVV
valid = validator.validate_cvv('123', 'visa')
print(valid) # True
# Get brand info
info = validator.get_brand_info('visa')
print(info['regexp_bin'])
# Get detailed brand info
detailed = validator.get_brand_info_detailed('amex')
print(detailed)
# List all brands
brands = validator.list_brands()
print(brands)
# ['amex', 'aura', 'banesecard', 'diners', 'discover', 'elo', 'hipercard', 'jcb', 'maestro', 'mastercard', 'unionpay', 'visa']
# Validate card number using Luhn algorithm
from creditcard_identifier.validator import luhn
is_valid = luhn('4012001037141112')
print(is_valid) # True
# Or using validator instance
is_valid = validator.luhn('4012001037141112')
print(is_valid) # True
API
Module Functions
find_brand(card_number, detailed=False)
Identify the credit card brand.
Parameters:
card_number(str): The credit card numberdetailed(bool): If True, returns detailed brand info (default: False)
Returns: (dict) Brand dict or None if not found
is_supported(card_number)
Check if the card number is supported.
Parameters:
card_number(str): The credit card number
Returns: (bool) True if supported, False otherwise
CreditCardValidator Class
__init__()
Initialize validator with embedded brand data.
find_brand(card_number, detailed=False)
Identify the credit card brand.
Parameters:
card_number(str): The credit card numberdetailed(bool): If True, returns detailed brand info with matched pattern
Returns: (dict) Brand dict or None if not found
is_supported(card_number)
Check if card number is supported.
Parameters:
card_number(str): The credit card number
Returns: (bool) True if supported, False otherwise
validate_cvv(cvv, brand_or_name)
Validate CVV for a specific brand.
Parameters:
cvv(str): CVV codebrand_or_name(str | dict): Brand name or brand dict from find_brand
Returns: (bool) True if valid, False otherwise
get_brand_info(brand_name)
Get information about a specific brand.
Parameters:
brand_name(str): Brand name
Returns: (dict) Brand information or None if not found
get_brand_info_detailed(scheme)
Get detailed information about a specific brand.
Parameters:
scheme(str): Scheme name (e.g., 'visa', 'mastercard')
Returns: (dict) Detailed brand information or None if not found
list_brands()
List all supported brands.
Returns: (list) List of brand names
luhn(number)
Validate a credit card number using the Luhn algorithm.
Parameters:
number(str): Credit card number (digits only)
Returns: (bool) True if valid according to Luhn algorithm
Raises: TypeError if input is not a string
Data Source
This library uses the BIN data from the bin-cc project.
The data is embedded directly in the package for optimal performance.
Development
Install in Development Mode
cd libs/python
pip install -e .
Run Tests
python -m pytest tests/
License
MIT
Metadata
Release files for creditcard-identifier 2.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| creditcard_identifier-2.3.0.tar.gz | 1.3 MB | With provenance | Details for creditcard_identifier-2.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| creditcard_identifier-2.3.0-py3-none-any.whl | Python 3 | none | any | Details for creditcard_identifier-2.3.0-py3-none-any.whl |
Total release size: 2.7 MB
Release files / creditcard_identifier-2.3.0.tar.gz
| Download URL | creditcard_identifier-2.3.0.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cbf494b6eaf31613dc2263f7e916b51d6623f27cfe7c9cf10993a07ac20e4451
|
|
BLAKE2b-256 checksum How to use checksums |
6ffba45a94e0bba62cd8fdea7a7b90bfc646008d97975e25f402542f61fc57c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 15, 2026.
Transparency logRelease files / creditcard_identifier-2.3.0-py3-none-any.whl
| Download URL | creditcard_identifier-2.3.0-py3-none-any.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e764122744136333a1282c4e4f014bdd24667369d2ce7249d9f7574a555e243
|
|
BLAKE2b-256 checksum How to use checksums |
1864876e25e33f29bd30b771f27a9f09a4e5dac12cf248a1e5ea6470058fc0f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 15, 2026.
Transparency logSecurity for creditcard-identifier 2.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for creditcard_identifier-2.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.