Skip to main content

Official Python SDK for the IBANforge API — IBAN validation, BIC/SWIFT lookup, Swiss BC-Nummer, sanctions/SEPA/VoP compliance triage.

Project description

IBANforge Python SDK

PyPI Python License

Official Python SDK for the IBANforge API — IBAN validation, BIC/SWIFT lookup, Swiss BC-Nummer, and sanctions/SEPA/VoP compliance triage.

Built for AI finance agents and fintech developers. Sync + async clients, full type hints, typed exceptions.

Install

pip install ibanforge

Get a free API key (1 line, no signup form)

from ibanforge import IBANforge

key = IBANforge.generate_api_key("you@example.com")
print(key["api_key"])  # ifk_… — store it, it's shown only once
print(key["monthly_limit"])  # 200 free requests/month

When the monthly quota is exhausted, the API automatically falls back to advertising x402 payment requirements (no dead-end). Your key resumes working at the start of the next month.

Quick start (sync)

from ibanforge import IBANforge

with IBANforge(api_key="ifk_...") as client:
    out = client.validate_iban("CH9300762011623852957")

    print(out["valid"])                  # True
    print(out["country"])                # {"code": "CH", "name": "Switzerland"}
    print(out["bic"]["bankName"])        # "UBS Switzerland AG"
    print(out["bic"]["lei"])             # "BFM8T61CT2L1QCEMIK50"
    print(out["sepa"])                   # {"reachable": True, "instant": True}
    print(out["vop"]["participant"])     # True
    print(out["ch_clearing"]["bc_nummer"])  # "762"
    print(out["risk_score"])             # 5

Quick start (async)

import asyncio
from ibanforge import AsyncIBANforge

async def main():
    async with AsyncIBANforge(api_key="ifk_...") as ibanforge:
        # Fan out 100 validations concurrently
        results = await asyncio.gather(*[
            ibanforge.validate_iban(iban) for iban in ibans
        ])
        valid = sum(1 for r in results if r["valid"])
        print(f"{valid}/{len(results)} valid")

asyncio.run(main())

All endpoints

Method Cost What it does
format_iban(iban) free Pure mod-97 + structure check. Use to pre-filter malformed IBANs before paying.
validate_iban(iban) $0.005 Full enrichment — BIC, country, EMI/vIBAN flag, SEPA + VoP, risk score, Swiss BC-Nummer for CH/LI
validate_batch([iban, ...]) $0.002 / IBAN Up to 100 IBANs in one call. CSV cleanup, payout list triage.
lookup_bic(code) $0.003 Resolve BIC/SWIFT into bank name, country, city, LEI, address. 121,399 BIC entries (38,761 LEI-enriched via GLEIF).
lookup_ch_clearing(iid) $0.003 Resolve a Swiss BC-Nummer / IID. The only API with this data.
check_compliance(iban) $0.02 Pre-flight risk triage: sanctions (OFAC/EU/UN), FATF, SEPA Instant, VoP, risk score 0-100, recommended_action ∈ {allow, review, block}
usage() free Current month quota usage for your key
health() free API version, BIC count, uptime

Free format check (no key needed)

Save money by pre-filtering bad IBANs before paying for enrichment:

from ibanforge import IBANforge

with IBANforge() as client:  # no api_key required
    out = client.format_iban("CH9300762011623852957")
    if not out["valid"]:
        print("Skip:", out["error"])      # e.g. "checksum_failed"
    else:
        print(out["bban"]["bank_code"])   # "00762"

Compliance triage (the killer feature)

out = client.check_compliance("RU1234567890123456789012345678")  # made-up RU
print(out["risk_score"])             # high (Russia + FATF flag)
print(out["recommended_action"])     # "block" | "review" | "allow"
print(out["sanctions"]["lists"])     # ["OFAC", "EU"] etc.
print(out["fatf"]["list"])           # "grey" | "black" | "none"
print(out["sepa"]["reachable"])

Error handling

The SDK raises typed exceptions — catch the specific class you care about, or the base IBANforgeError:

from ibanforge import (
    IBANforge,
    AuthError, PaymentRequiredError, QuotaExhaustedError,
    RateLimitError, InvalidInputError, APIError, IBANforgeError,
)

with IBANforge(api_key="ifk_...") as client:
    try:
        out = client.validate_iban("not-an-iban")
    except InvalidInputError as e:
        print(e.body["error"])  # "invalid_format"
    except AuthError:
        print("Bad or revoked API key")
    except PaymentRequiredError as e:
        # Your quota is exhausted — switch to x402 to keep going
        print(e.body["accepts"])  # x402 payment requirements
    except RateLimitError:
        print("Slow down")
    except APIError as e:
        print(f"Server error {e.status} — retry with backoff")
    except IBANforgeError as e:
        print(f"Other: {e}")

For LLM agents (LangChain, LlamaIndex, CrewAI, AutoGen)

The IBANforge API is also available as a native MCP server (npx -y ibanforge-mcp) and via x402 micropayments — see the agent guide. For Python-first agents, the SDK above is usually enough.

Configuration

client = IBANforge(
    api_key="ifk_...",
    base_url="https://api.ibanforge.com",  # default
    timeout=30.0,                          # seconds, default
    user_agent="my-app/1.2",               # custom UA
)

Links

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

ibanforge-1.3.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

ibanforge-1.3.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file ibanforge-1.3.0.tar.gz.

File metadata

  • Download URL: ibanforge-1.3.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ibanforge-1.3.0.tar.gz
Algorithm Hash digest
SHA256 83745f7881023c646b9f409c2b3e4ec3a1f58488b796f95bff6ef72180b36f24
MD5 e4795eb8fd67fe95ba2c171531fcf8ab
BLAKE2b-256 a975b240e37e39564672db2b2b6dd8497e61d763a2b084d2a04e1623b90caced

See more details on using hashes here.

File details

Details for the file ibanforge-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: ibanforge-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ibanforge-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b94e4d96d483778a43deb59d97dfb72b97960d44439ef0c688346773266fd9e8
MD5 c2ccb262c7e852b0bae32762f096f254
BLAKE2b-256 8a0836db1503be487a738680754ab2ee9b70066077a48be5e5468650261151a1

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