faker.providers.bank¶
- class faker.providers.bank.Provider(generator: Any)¶
Bases:
BaseProviderImplement default bank provider for Faker.
Important
Bank codes, account numbers, and other ID’s generated by this provider are only valid in form, i.e. they conform to some standard/format, are of the expected lengths, and have valid checksums (where applicable). Results generated that turn out to be valid in real life are purely coincidental.
Sources:
- aba() str¶
Generate an ABA routing transit number.
- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.aba() ... '076048766' '057593829' '052194896' '034115783' '025659384'
- bank_country() str¶
Generate the bank provider’s ISO 3166-1 alpha-2 country code.
- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.bank_country() ... 'GB' 'GB' 'GB' 'GB' 'GB'
- bban() str¶
Generate a Basic Bank Account Number (BBAN).
- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.bban() ... 'MYNB48764759382421' 'TZIR92411578156593' 'RPOQ40801609753513' 'SHHZ28711587148418' 'KRGZ98947196593423'
- iban() str¶
Generate an International Bank Account Number (IBAN).
- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.iban() ... 'GB84MYNB48764759382421' 'GB13TZIR92411578156593' 'GB51RPOQ40801609753513' 'GB03SHHZ28711587148418' 'GB56KRGZ98947196593423'
- swift(length: int | None = None, primary: bool = False, use_dataset: bool = False) str¶
Generate a SWIFT code.
SWIFT codes, reading from left to right, are composed of a 4 alphabet character bank code, a 2 alphabet character country code, a 2 alphanumeric location code, and an optional 3 alphanumeric branch code. This means SWIFT codes can only have 8 or 11 characters, so the value of
lengthcan only beNoneor the integers8or11. If the value isNone, then a value of8or11will randomly be assigned.Because all 8-digit SWIFT codes already refer to the primary branch or office, the
primaryargument only has an effect if the value oflengthis11. IfprimaryisTrueandlengthis11, the 11-digit SWIFT codes generated will always end in'XXX'to denote that they belong to primary branches/offices.For extra authenticity, localized providers may opt to include SWIFT bank codes, location codes, and branch codes used in their respective locales. If
use_datasetisTrue, this method will generate SWIFT codes based on those locale-specific codes if included. If those codes were not included, then it will behave as ifuse_datasetwereFalse, and in that mode, all those codes will just be randomly generated as per the specification.- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift() ... 'YNBIGB65ZT4' 'SGQEGBSIGQ8' 'JDXCGBV4' 'LNKTGBN9' 'OQIBGB9AFZA'
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift(length=8) ... 'MYNBGBQ6' 'PMZJGB4W' 'SGQEGBSI' 'YDTZGBQ8' 'WZTEGBTG'
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift(length=8, use_dataset=True) ... 'MYNBGBQ6' 'PMZJGB4W' 'SGQEGBSI' 'YDTZGBQ8' 'WZTEGBTG'
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift(length=11) ... 'MYNBGBQ65ZT' 'PLSGGB6ISIG' 'TZIRGBJTGEV' 'PRDLGB1UN94' 'OQIBGB9AFZA'
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift(length=11, primary=True) ... 'MYNBGBQ6XXX' 'PMZJGB4WXXX' 'SGQEGBSIXXX' 'YDTZGBQ8XXX' 'WZTEGBTGXXX'
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift(length=11, use_dataset=True) ... 'MYNBGBQ65ZT' 'PLSGGB6ISIG' 'TZIRGBJTGEV' 'PRDLGB1UN94' 'OQIBGB9AFZA'
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift(length=11, primary=True, use_dataset=True) ... 'MYNBGBQ6XXX' 'PMZJGB4WXXX' 'SGQEGBSIXXX' 'YDTZGBQ8XXX' 'WZTEGBTGXXX'
- swift11(primary: bool = False, use_dataset: bool = False) str¶
Generate an 11-digit SWIFT code.
This method uses
swift()under the hood with thelengthargument set to11. Ifprimaryis set toTrue, the SWIFT code will always end with'XXX'. All 11-digit SWIFT codes use this convention to refer to the primary branch/office.- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift11() ... 'MYNBGBQ65ZT' 'PLSGGB6ISIG' 'TZIRGBJTGEV' 'PRDLGB1UN94' 'OQIBGB9AFZA'
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift11(use_dataset=True) ... 'MYNBGBQ65ZT' 'PLSGGB6ISIG' 'TZIRGBJTGEV' 'PRDLGB1UN94' 'OQIBGB9AFZA'
- swift8(use_dataset: bool = False) str¶
Generate an 8-digit SWIFT code.
This method uses
swift()under the hood with thelengthargument set to8and with theprimaryargument omitted. All 8-digit SWIFT codes already refer to the primary branch/office.- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift8() ... 'MYNBGBQ6' 'PMZJGB4W' 'SGQEGBSI' 'YDTZGBQ8' 'WZTEGBTG'
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift8(use_dataset=True) ... 'MYNBGBQ6' 'PMZJGB4W' 'SGQEGBSI' 'YDTZGBQ8' 'WZTEGBTG'