Skip to main content

Nigerian Bank Account Number prediction. Get a list of possible Nigerian banks based on an account number

Project description

py-nuban

Lightweight Python utilities to detect possible Nigerian banks for a given Nigerian Bank Account Number. Useful for validation, or bank account suggestions in payment flows.

Installation

Install from PyPI when published:

	pip install py-nuban

Or install for development from the repository root:

	pip install -e .

Quick start

from py_nuban import get_possible_banks

banks = get_possible_banks("1901880678")
print(banks)  # e.g. [('033', 'United Bank for Africa'), ('044', 'Access Bank Nigeria')]

What this package does

  • Validates a 10-digit NUBAN account number (type and length checks).
  • Runs the NUBAN checksum algorithm against all known bank codes and returns the banks whose code+serial produce the same check digit.
  • Adds simple heuristics for phone-linked accounts and Moniepoint-style accounts so those non-standard account numbers are also considered.
  • Filters results by a manually-assigned popularity score to surface commonly used banks first.

NUBAN algorithm

To validate a Nigerian bank account number, the system uses the official NUBAN check-digit algorithm. Here's how it works: The account number consists of a bank code, a serial number(the first 9 digits of an account number), and a check digit(the last digit of an account number). Because Nigerian banks use bank codes of different lengths (3, 5, or 6 digits), the code first normalizes every bank code to a standard format:

3-digit codes get padded with 000 at the front. 5-digit codes get a 9 added at the front. 6-digit codes are used as-is.

This normalized bank code is then combined with the serial number portion of the account to form a 15-character string. Each of these 15 digits is multiplied by a specific weight from this sequence:

[3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3]

All the results are added together. The system then calculates what the correct check digit should be (using modulo 10 arithmetic). If the calculated check digit matches the one provided in the account number, the NUBAN is considered valid for that bank. This process is repeated across all known banks until a match is found. The result is a reliable way to verify that an account number is correctly formed for its issuing bank.

Example (demo):

# account: 1901880678
# serial = '190188067'  (first 9 digits)
# check  = '8'          (last digit)
from py_nuban import get_possible_banks
print(get_possible_banks('1901880678'))
# Example output (depends on the bundled bank data):
# [('033', 'United Bank for Africa'), ('044', 'Access Bank Nigeria')]

Limitations and how this package helps

  • Many new or smaller microfinance/payment institutions sometimes use non-standard codes and algorithms to generate their account numbers. That means the NUBAN check alone can miss or misidentify such accounts.
  • To reduce false positives and surface useful results we:
    • Add simple prefix checks (common phone-number prefixes) to detect phone-linked accounts and include microfinance providers where applicable.
    • Use a manual popularity numeric field per bank in the bundled data to filter out rarely-used entries. This is a pragmatic heuristic to make results more useful in real apps; it is not a guarantee of correctness.

These heuristics make the library more practical in production, but they also introduce opinionated filtering — see the next section.

Accuracy and safety notes

  • Results are a best-effort list of candidate banks, not absolute guarantees. Always treat matches as suggestions and confirm with a reliable resolver service (like Korapay) or the bank when accuracy is critical. You should also ideally provide a fallback for the user to select the bank they use manually

Contributing

Contributions welcome. Please open an issue for data updates, bug reports, or feature requests. Include tests and small focused changes. Add a unit test under tests/ and update documentation as needed.

Testing & CI

  • Run the small test harness included in tests/test_main.py:

License

This project is MIT licensed — 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

py_nuban-0.1.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

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

py_nuban-0.1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file py_nuban-0.1.0.tar.gz.

File metadata

  • Download URL: py_nuban-0.1.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for py_nuban-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2d61794c460e58225a97cd47c9af37a487ce832d23ea711bf3321bbcf7e9f0ec
MD5 60288d508b3b4a8d31f4e2cd741e550f
BLAKE2b-256 903b6aea80f92435659f727649056cd5b09d371693ab79fda7a891aca907fd77

See more details on using hashes here.

File details

Details for the file py_nuban-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_nuban-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for py_nuban-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b208e7f7af3aa14da7cb51ecca654a7601a8c527b3c0c1dc40dce9d36d4ca21c
MD5 8cd898238d93897c773fba7a57d69226
BLAKE2b-256 2ee44ebff66b8ebca2992e6bcf11d1ac3f1e390d518dee6af0c86c22bc6c7a1b

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