Skip to main content

A Python library for retrieving BIN (Bank Identification Number) information.

Project description

binDB

Credit: This library is a synchronous adaptation of the original smartbindb library which is asynchronous found at https://pypi.org/project/smartbindb/.

A Python library for retrieving BIN (Bank Identification Number) information.

Installation

You can install binDB using pip:

pip install binDB

Usage

from binDB import BinDB

db = BinDB()

# Get BIN information
bin_info = db.get_bin_info("45717360")
print(bin_info)

# Get BINs by bank name
bank_bins = db.get_bins_by_bank("JPMorgan Chase", limit=5)
print(bank_bins)

# Get BINs by country code
country_bins = db.get_bins_by_country("US", limit=5)
print(country_bins)

Available Methods (Endpoints)

The BinDB class provides the following methods for interacting with BIN data:

get_bin_info(bin: str) -> dict

Retrieves detailed information for a specific BIN.

  • bin: The 6-digit BIN to look up.

get_bins_by_bank(bank: str, limit: Optional[int] = None, fuzzy_match_threshold: int = 80) -> dict

Retrieves BINs associated with a specific bank name. Supports fuzzy matching.

  • bank: The name of the bank to search for.
  • limit: (Optional) Maximum number of results to return.
  • fuzzy_match_threshold: (Optional) Score threshold for fuzzy matching (default: 80).

get_bins_by_country(country: str, limit: Optional[int] = None, randomize: bool = False) -> dict

Retrieves BINs for a specific country.

  • country: The two-letter ISO country code (e.g., "US", "GB").
  • limit: (Optional) Maximum number of results to return.
  • randomize: (Optional) If True, returns a random sample of BINs (default: False).

get_bins(country_code: Optional[str] = None, limit: int = 10, randomize: bool = False) -> dict

Retrieves a list of BINs, optionally filtered by country.

  • country_code: (Optional) The two-letter ISO country code. If None, retrieves BINs from all countries.
  • limit: Maximum number of results to return (default: 10).
  • randomize: If True, returns a random sample of BINs (default: False).

get_all_bank_names(country_code: Optional[str] = None, count_bins: bool = False) -> List[Dict]

Retrieves a list of all unique bank names in the database, optionally filtered by country and with BIN counts.

  • country_code: (Optional) The two-letter ISO country code.
  • count_bins: If True, includes the count of BINs for each bank (default: False).

get_total_bins_count() -> int

Returns the total number of unique BINs loaded in the database.

get_country_bin_counts() -> dict

Returns a dictionary with country codes as keys and the number of BINs for each country as values, sorted by count in descending order.

Data

The library uses JSON files located in the data/ directory for BIN information.

Contributing

Feel free to contribute to this project by opening issues or pull requests on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

binDB

A Python library for retrieving BIN (Bank Identification Number) information.

Installation

You can install binDB using pip:

pip install binDB

Usage

from binDB.smartdb import SmartBinDB

db = SmartBinDB()

# Get BIN information
bin_info = db.get_bin_info("45717360")
print(bin_info)

# Get BINs by bank name
bank_bins = db.get_bins_by_bank("JPMorgan Chase", limit=5)
print(bank_bins)

# Get BINs by country code
country_bins = db.get_bins_by_country("US", limit=5)
print(country_bins)

Available Methods (Endpoints)

The SmartBinDB class provides the following methods for interacting with BIN data:

get_bin_info(bin: str) -> dict

Retrieves detailed information for a specific BIN.

  • bin: The 6-digit BIN to look up.

get_bins_by_bank(bank: str, limit: Optional[int] = None, fuzzy_match_threshold: int = 80) -> dict

Retrieves BINs associated with a specific bank name. Supports fuzzy matching.

  • bank: The name of the bank to search for.
  • limit: (Optional) Maximum number of results to return.
  • fuzzy_match_threshold: (Optional) Score threshold for fuzzy matching (default: 80).

get_bins_by_country(country: str, limit: Optional[int] = None, randomize: bool = False) -> dict

Retrieves BINs for a specific country.

  • country: The two-letter ISO country code (e.g., "US", "GB").
  • limit: (Optional) Maximum number of results to return.
  • randomize: (Optional) If True, returns a random sample of BINs (default: False).

get_bins(country_code: Optional[str] = None, limit: int = 10, randomize: bool = False) -> dict

Retrieves a list of BINs, optionally filtered by country.

  • country_code: (Optional) The two-letter ISO country code. If None, retrieves BINs from all countries.
  • limit: Maximum number of results to return (default: 10).
  • randomize: If True, returns a random sample of BINs (default: False).

get_all_bank_names(country_code: Optional[str] = None, count_bins: bool = False) -> List[Dict]

Retrieves a list of all unique bank names in the database, optionally filtered by country and with BIN counts.

  • country_code: (Optional) The two-letter ISO country code.
  • count_bins: If True, includes the count of BINs for each bank (default: False).

get_total_bins_count() -> int

Returns the total number of unique BINs loaded in the database.

get_country_bin_counts() -> dict

Returns a dictionary with country codes as keys and the number of BINs for each country as values, sorted by count in descending order.

Data

The library uses JSON files located in the data/ directory for BIN information.

Contributing

Feel free to contribute to this project by opening issues or pull requests on GitHub.

License

This project is licensed under the 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

bindb-0.1.8.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bindb-0.1.8-py3-none-any.whl (3.0 MB view details)

Uploaded Python 3

File details

Details for the file bindb-0.1.8.tar.gz.

File metadata

  • Download URL: bindb-0.1.8.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for bindb-0.1.8.tar.gz
Algorithm Hash digest
SHA256 6782e96d81781998b729dd7f5c89198b09bc8786e6fc8a7e4517edf09f2365cb
MD5 9b97dc5f1febfecfeec30450e73759b9
BLAKE2b-256 f9a1148fc65821f0eeb33c24f4ff9eac58839b88abbdaf1850fc1d5840c89b8a

See more details on using hashes here.

File details

Details for the file bindb-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: bindb-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for bindb-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f3fcac832f331318996c0f3229f24444e946a622dde3da89a62cad3edd5377f4
MD5 03eecc5b69cf3ff6899439456739f5be
BLAKE2b-256 6c90092282cc44d996b11a5b3af56cb42b80e86d12401faa536ea2ec4dbf428c

See more details on using hashes here.

Supported by

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