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.1.tar.gz (10.3 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.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ibanforge-1.3.1.tar.gz
Algorithm Hash digest
SHA256 e2239bcf039c8e3b491e149a7bcca27dcb7814f70c60b7d43cf693a85e8c8206
MD5 3ffc04f8975712b34f13bd8776036cfd
BLAKE2b-256 1b7926db9bfed0e8de774f14846787f00aa600b2bf47b5b4a5e6ed0885799bb2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ibanforge-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 505d4904070a168148a6adcba54cece346cf56971aa1bcd50a50cf2351db96d0
MD5 702c6ff2e642b52afc27ff25e218a5f6
BLAKE2b-256 0f5e2cf7a6da35bcc4624144fd90a9006f9ff60d3512849ee3afbfb550c5b74b

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