faker.providers.bank

class faker.providers.bank.Provider(generator)

Bases: faker.providers.BaseProvider

Provider for IBAN/BBAN: it generates valid (valid length, valid checksum) IBAN/BBANs for the given country. But the ids of the banks are random and not valid banks! Same for account numbers.

bank_country()
Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.bank_country()
...
'GB'
'GB'
'GB'
'GB'
'GB'
bban()
Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.bban()
...
'VTKG87647593824219'
'UZNS92411578156593'
'ZMWG80160975351393'
'GZUL15871484185839'
'OHCU59342320947112'
iban()
Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.iban()
...
'GB22VTKG87647593824219'
'GB75UZNS92411578156593'
'GB07ZMWG80160975351393'
'GB75GZUL15871484185839'
'GB82OHCU59342320947112'
swift(length=None, primary=None, use_dataset=False)

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 length can only be None or the integers 8 or 11. If the value is None, then a value of 8 or 11 will randomly be assigned.

Because all 8-digit SWIFT codes already refer to the primary branch/office, the primary argument only has an effect if the value of length is 11. If primary is True and length is 11, 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_dataset is True, 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 if use_dataset were False, 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()
...
'TKGNGBO2KRV'
'NHTQGBJ6936'
'SXRMGBDP'
'XZMWGBJ2TAZ'
'VRAMGB5I'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.swift(length=8)
...
'VTKGGBSO'
'UHMPGB6S'
'HTQGGB69'
'VXISGB6Y'
'MCLPGB68'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.swift(length=8, use_dataset=True)
...
'VTKGGBSO'
'UHMPGB6S'
'HTQGGB69'
'VXISGB6Y'
'MCLPGB68'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.swift(length=11)
...
'VTKGGBSO2KR'
'PXNHGB1WJ69'
'VXISGB6YQDP'
'PXZMGB5J2TA'
'SKVRGBAR5IL'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.swift(length=11, primary=True)
...
'VTKGGBSOXXX'
'UHMPGB6SXXX'
'HTQGGB69XXX'
'VXISGB6YXXX'
'MCLPGB68XXX'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.swift(length=11, use_dataset=True)
...
'VTKGGBSO2KR'
'PXNHGB1WJ69'
'VXISGB6YQDP'
'PXZMGB5J2TA'
'SKVRGBAR5IL'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.swift(length=11, primary=True, use_dataset=True)
...
'VTKGGBSOXXX'
'UHMPGB6SXXX'
'HTQGGB69XXX'
'VXISGB6YXXX'
'MCLPGB68XXX'
swift11(primary=None, use_dataset=False)

Generate an 11-digit SWIFT code

This method uses swift() under the hood with the length argument set to 11. If primary is set to True, 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()
...
'VTKGGBSO2KR'
'PXNHGB1WJ69'
'VXISGB6YQDP'
'PXZMGB5J2TA'
'SKVRGBAR5IL'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.swift11(use_dataset=True)
...
'VTKGGBSO2KR'
'PXNHGB1WJ69'
'VXISGB6YQDP'
'PXZMGB5J2TA'
'SKVRGBAR5IL'
swift8(use_dataset=False)

Generate an 8-digit SWIFT code

This method uses swift() under the hood with the length argument set to 8 and with the primary argument omitted. All 8-digit SWIFT codes already refer to the primary branch/office.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.swift8()
...
'VTKGGBSO'
'UHMPGB6S'
'HTQGGB69'
'VXISGB6Y'
'MCLPGB68'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.swift8(use_dataset=True)
...
'VTKGGBSO'
'UHMPGB6S'
'HTQGGB69'
'VXISGB6Y'
'MCLPGB68'