faker.providers.bank¶
-
class
faker.providers.bank.Provider(generator)¶ Bases:
faker.providers.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:
- https://en.wikipedia.org/wiki/International_Bank_Account_Number
- https://www.theswiftcodes.com/swift-code-checker/
-
bank_country()¶ 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()¶ Generate a Basic Bank Account Number (BBAN).
Examples: >>> Faker.seed(0) >>> for _ in range(5): ... fake.bban() ... 'VTKG87647593824219' 'UZNS92411578156593' 'ZMWG80160975351393' 'GZUL15871484185839' 'OHCU59342320947112'
-
iban()¶ Generate an International Bank Account Number (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
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() ... '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 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() ... '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 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() ... 'VTKGGBSO' 'UHMPGB6S' 'HTQGGB69' 'VXISGB6Y' 'MCLPGB68'
>>> Faker.seed(0) >>> for _ in range(5): ... fake.swift8(use_dataset=True) ... 'VTKGGBSO' 'UHMPGB6S' 'HTQGGB69' 'VXISGB6Y' 'MCLPGB68'