Skip to content

Repository files navigation

ibanchecker

Official Python client for the ibanchecker.cash IBAN validation API.

Validate IBANs across 92 countries, validate up to 100 IBANs per request, extract IBANs from free text, look up country format specifications, and resolve SWIFT/BIC codes. No IBAN data is stored or logged; all validation runs in memory at the edge.

Install

pip install ibanchecker

Quick start

fromibancheckerimportIbanCheckerclient=IbanChecker() # no API key needed for light use (100 requests/hour per IP)result=client.validate("DE89 3704 0044 0532 0130 00")
ifresult: # ValidationResult is truthy when validprint(result.country_name) # "Germany"print(result.bank_name) # "Commerzbank AG Cologne"print(result.bic) # "COBADEFFXXX"else:
print(result.error) # human-readable reasonprint(result.error_code) # e.g. "INVALID_LENGTH"

Authentication

An API key is optional. Without one, requests are limited to 100 per hour per IP. With a key, requests count against your plan quota. Get a free key at ibanchecker.cash/api-docs.

client=IbanChecker("iban_your_api_key")

The client can also be used as a context manager so the underlying HTTP session is closed cleanly:

withIbanChecker("iban_your_api_key") asclient:
result=client.validate("GB29 NWBK 6016 1331 9268 19")

Methods

MethodDescription
validate(iban)Validate a single IBAN. Returns a ValidationResult.
validate_bulk(ibans)Validate up to 100 IBANs. Returns a BatchResult.
extract(text)Find and validate IBANs in free text (up to 50,000 chars). Returns a BatchResult.
get_format(country)IBAN format spec for an ISO country code. Returns a FormatSpec.
lookup_bic(bic)Resolve an 8 or 11 character BIC. Returns a BankRecord.

Bulk validation

batch=client.validate_bulk([
"DE89370400440532013000",
"GB29NWBK60161331926819",
"XX00",
])
print(batch.valid_count, "of", batch.count, "valid")
forrinbatch: # iterate results in input orderprint(r.iban, r.valid)

Extract from text

batch=client.extract("Please wire to DE89 3704 0044 0532 0130 00 by Friday.")
forrinbatch:
print(r.iban, r.bank_name)

Country format and BIC lookup

fmt=client.get_format("DE")
print(fmt.length, fmt.example) # 22 'DE89370400440532013000'bank=client.lookup_bic("DEUTDEFF")
print(bank.bank_name, bank.city) # 'Deutsche Bank AG Frankfurt' 'FRANKFURT AM MAIN'

Error handling

A malformed IBAN is not an exception: validate() returns a ValidationResult with valid=False. Exceptions are raised only for transport, authentication, and rate-limit problems:

fromibancheckerimportIbanChecker, AuthenticationError, RateLimitError, NotFoundErrorclient=IbanChecker("iban_your_api_key")
try:
bank=client.lookup_bic("ZZZZZZZZ")
exceptNotFoundError:
print("No bank for that BIC")
exceptRateLimitErrorase:
print("Slow down:", e.message)
exceptAuthenticationError:
print("Check your API key")

All exceptions derive from IbanCheckerError and carry .status, .error_code, and .response.

Links

License

MIT

About

Official Python client for the ibanchecker.cash API. Validate IBANs across 92 countries, extract IBANs from text, and look up SWIFT/BIC codes.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages