IBANforge
← Back to blog

How to Validate IBANs and Look Up BIC Codes with a Single API

·5 min read

How to Validate IBANs and Look Up BIC Codes with a Single API

International bank transfers live and die on two pieces of data: the IBAN that identifies the account, and the BIC that routes the payment to the right bank. Get either wrong and your transaction is delayed, bounced, or rejected by the receiving institution — sometimes without a useful error message. For any application that touches cross-border payments, compliance workflows, or customer onboarding, validating both fields before submitting is not optional.

The problem with IBAN validation

A naive implementation checks whether the string looks like an IBAN. That is not enough.

Real IBAN validation requires three things: the correct length for the specific country (which varies from 15 digits for Norway to 34 for Malta), a passing mod-97 checksum on the rearranged number string, and correct BBAN structure — the bank code, branch code, and account number sub-fields that are embedded in the IBAN according to each country's own banking format.

Then there is the BIC problem. Even if an IBAN is structurally valid, you often need to know which bank it belongs to — for display purposes, for compliance screening, or for routing decisions. The bank code embedded in the BBAN tells you something, but mapping it to an actual BIC and institution name requires a separate database. Most teams either skip this step entirely or pay for a second API call.

IBANforge: one API for both

IBANforge is a REST API that handles full IBAN validation — checksum, country rules, BBAN parsing — and resolves the BIC code in the same response, against the 39,000+ entry GLEIF dataset used by central banks. One POST request, one structured JSON response.

There is a free /v1/demo endpoint to test your parser without touching the paid endpoints, and an interactive playground if you want to paste an IBAN and see what comes back before writing a line of code.

Example 1: Validate an IBAN with curl

curl -X POST https://api.ibanforge.com/v1/iban/validate \
  -H "Content-Type: application/json" \
  -d '{"iban": "CH93 0076 2011 6238 5295 7"}'

Response:

{
  "iban": "CH9300762011623852957",
  "valid": true,
  "country": { "code": "CH", "name": "Switzerland" },
  "check_digits": "93",
  "bban": { "bank_code": "00762", "account_number": "011623852957" },
  "formatted": "CH93 0076 2011 6238 5295 7",
  "cost_usdc": 0.005,
  "bic": { "code": "UBSWCHZH", "bank_name": "UBS Switzerland AG", "city": "Zurich" },
  "processing_ms": 9.11
}

A few things worth noting in this response:

  • valid: true confirms both the mod-97 checksum and the country-specific length and format rules passed.
  • iban returns the compact form (no spaces); formatted adds spaces in the standard 4-character grouping.
  • bban.bank_code is extracted from the BBAN according to Switzerland's specific format — not just a substring operation.
  • The bic object includes the bank name and city, resolved from the GLEIF dataset.

If validation fails, the response includes an error field with a machine-readable error code (checksum_failed, wrong_length, unsupported_country, etc.) so you can distinguish a typo from an unsupported country code.

Example 2: Python

import httpx

response = httpx.post(
    "https://api.ibanforge.com/v1/iban/validate",
    json={"iban": "DE89 3704 0044 0532 0130 00"}
)
result = response.json()
print(f"Valid: {result['valid']}, Bank: {result.get('bic', {}).get('bank_name')}")

This uses httpx to call the REST API directly. You can also use requests or any other HTTP client — the endpoint works exactly as shown in the curl example above.

Example 3: TypeScript

const res = await fetch('https://api.ibanforge.com/v1/iban/validate', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ iban: 'GB29 NWBK 6016 1331 9268 19' }),
});
const result = await res.json();
console.log(result.bic?.bank_name);

This works in any JavaScript/TypeScript environment — Next.js API routes, edge functions, Node.js scripts, or browser code. The bic field is optional because BIC lookup is not available for every country, so always use optional chaining when accessing it.

Batch validation

If you are processing a CSV import, validating a list of creditors during onboarding, or running a nightly reconciliation job, the /v1/iban/batch endpoint accepts up to 100 IBANs in a single request and returns per-IBAN results at a flat rate of $0.020 USDC — not per-item billing. Each result in the array has the same structure as a single validation response, including BIC enrichment where available.

curl -X POST https://api.ibanforge.com/v1/iban/batch \
  -H "Content-Type: application/json" \
  -d '{
    "ibans": [
      "CH93 0076 2011 6238 5295 7",
      "DE89 3704 0044 0532 0130 00",
      "GB29 NWBK 6016 1331 9268 19"
    ]
  }'

For AI agents: MCP integration

IBANforge ships with a built-in Model Context Protocol server, exposing validate_iban, batch_validate_iban, and lookup_bic as native tools. Any MCP-compatible agent — Claude, Cursor, or an open-source model — can call these tools directly without custom wrappers. If you are building an agentic workflow that touches payment data, this lets validation happen at the tool level rather than relying on the model to get IBAN formats right.

Get started

  • Playgroundibanforge.com/playground: paste any IBAN, see the full response live, no setup required.
  • Free demo endpointGET https://api.ibanforge.com/v1/demo: returns example validations for a handful of countries, no payment needed.
  • Documentationibanforge.com/docs: full endpoint reference, request/response schemas, error codes, and integration guides.

Payments use the x402 protocol — fractions of a cent in USDC per request, no API key, no subscription. The demo endpoint and playground are always free.