0

Validate International IBANs and obtain essential information

by
Published Apr 8, 2025

This method enables you to validate International Bank Account Numbers (IBANs) and obtain essential information about the country associated with each IBAN. By using this API, you can ensure that the IBANs are formatted correctly and gain insights into the banking institution, enhancing security and accuracy in financial transactions.

Script greip Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Greip = {
3
  apiKey: string;
4
};
5
/**
6
 * Validate International IBANs and obtain essential information
7
 * This method enables you to validate International Bank Account Numbers (IBANs) and obtain essential information about the country associated with each IBAN.
8

9
By using this API, you can ensure that the IBANs are formatted correctly and gain insights into the banking institution, enhancing security and accuracy in financial transactions.
10
 */
11
export async function main(
12
  auth: Greip,
13
  iban: string,
14
  format: string | undefined,
15
  userID: string | undefined,
16
  mode: string | undefined,
17
  callback: string | undefined,
18
) {
19
  const url = new URL(`https://greipapi.com/lookup/iban`);
20
  for (const [k, v] of [
21
    ["iban", iban],
22
    ["format", format],
23
    ["userID", userID],
24
    ["mode", mode],
25
    ["callback", callback],
26
  ]) {
27
    if (v !== undefined && v !== "" && k !== undefined) {
28
      url.searchParams.append(k, v);
29
    }
30
  }
31
  const response = await fetch(url, {
32
    method: "GET",
33
    headers: {
34
      Authorization: "Bearer " + auth.apiKey,
35
    },
36
    body: undefined,
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.text();
43
}
44