bank-codes
v1.3.9
Published
An extraction facility for https://bank.codes
Downloads
7
Readme
Bank Codes
A package that allows the caller to extrace SWIFT codes published by the http://bank.codes service
Install
Add to your project from the NPM repository:
npm install bank-codes --save
and grab an instance:
// using ES6 modules
import bc from 'bank-codes';
// using CommonJS modules
const bc = require('bank-codes');
Usage
The methods in this package store the data retrieved into a cache.json
file. This package contains such a file and most clients will simply want to use it directly, rather than scanning the site for the data. The file may be included like this:
const bc = require('bank-codes/cache.json')
The following methods are available in the package:
countries()
Returns an object keyed by country names and values a path within the site see a list of banks
{
"United States": "/swift-code/united-states/"
}
banks(country)
Retrieves the list of banks for the given country. The return value is similar that below:
[
{
"Name": "1ST PMF BANCORP",
"City": "LOS ANGELES",
"Branch": "",
"SWIFT": "PMFAUS66HKG"
}
]
Examples
The methods return promises so their return values need to be waited for
// as a promise
bc.banks('United States').then(console.log);
// async/await
(async () => {
console.log(await bc.banks('United States'));
})()
Notes
The cache file produced when calling package methods may become stale across time and can be regenerated by running:
npm run cache
Additionally, country lists of banks can be generated on the command line by adding the country names to the command (titlecased) e.g.
npm run cache Mexico Sweden
will output progress information to stderr and the output to stdout so it can be captured:
npm run cache Mexico > Mexico.json
Contribute
If you add functionality, make sure tests pass:
npm test
and when publishing, bump up the version like this:
npm version <patch|minor|major>
Licence
ISC
Support
For support post an issue on Github or reach out to me directly @ekkis on Telegram