Credit card BIN validation using bin-cc data
Project description
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']
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
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file creditcard_identifier-2.0.1.tar.gz.
File metadata
- Download URL: creditcard_identifier-2.0.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7360b59ad1a30ade7e4f5bc40197eb29687cb8b7c0e726fd28531fffdbb1e29e
|
|
| MD5 |
964477915e71072876c8d1b3dba7c3ac
|
|
| BLAKE2b-256 |
8039f8857d8e1ff9934c1d71997dd50c540b3f818e67e689196dde01cf6832e7
|
Provenance
The following attestation bundles were made for creditcard_identifier-2.0.1.tar.gz:
Publisher:
release.yml on renatovico/bin-cc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
creditcard_identifier-2.0.1.tar.gz -
Subject digest:
7360b59ad1a30ade7e4f5bc40197eb29687cb8b7c0e726fd28531fffdbb1e29e - Sigstore transparency entry: 813924640
- Sigstore integration time:
-
Permalink:
renatovico/bin-cc@4aca56c44bc9d7d711df0f865c2248901694ac05 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/renatovico
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4aca56c44bc9d7d711df0f865c2248901694ac05 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file creditcard_identifier-2.0.1-py3-none-any.whl.
File metadata
- Download URL: creditcard_identifier-2.0.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a32c9440098eeaa9bc174d387f5661958f5a08114c4b481fbc078eb1fedd4af0
|
|
| MD5 |
fb18785a2c81654b8dfac71a529da6d8
|
|
| BLAKE2b-256 |
394727ec8b3fda3d180f73495390847553b4a89b1639151b2b0d7b38001e32b4
|
Provenance
The following attestation bundles were made for creditcard_identifier-2.0.1-py3-none-any.whl:
Publisher:
release.yml on renatovico/bin-cc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
creditcard_identifier-2.0.1-py3-none-any.whl -
Subject digest:
a32c9440098eeaa9bc174d387f5661958f5a08114c4b481fbc078eb1fedd4af0 - Sigstore transparency entry: 813924659
- Sigstore integration time:
-
Permalink:
renatovico/bin-cc@4aca56c44bc9d7d711df0f865c2248901694ac05 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/renatovico
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4aca56c44bc9d7d711df0f865c2248901694ac05 -
Trigger Event:
workflow_dispatch
-
Statement type: