Lookup currency codes based on ISO 4217
npm install @winterrdog/currency-codesA node.js module to list and work on currency codes based on the ISO 4217 standard. This package has zero dependencies therefore it is lightweight if you care about small bundle sizes.
npm i @winterrdog/currency-codes
``js
import cc from "currency-codes";
console.log(cc.code("EUR"));
/*
{
code: 'EUR',
number: 978,
digits: 2,
currency: 'Euro',
countries: [
'andorra', 'austria', 'belgium', 'cyprus', 'estonia', 'finland',
'france', 'germany', 'greece', 'ireland', 'italy', 'kosovo',
'luxembourg', 'malta', 'monaco', 'montenegro', 'netherlands',
'portugal', 'san marino', 'slovakia', 'slovenia', 'spain',
'vatican city' ]
}
*/
`
`js
import cc from "currency-codes";
console.log(cc.number(967));
/*
{
code: 'ZMW',
number: 967,
digits: 2,
currency: 'Zambian kwacha',
countries: [ 'zambia' ] }
*/
`
`js
import cc from "currency-codes";
console.log(cc.country("colombia"));
/*
[
{
code: 'COP',
number: 170,
digits: 2,
currency: 'Colombian peso',
countries: [ 'colombia' ]
}, {
code: 'COU',
number: 970,
digits: 2,
currency: 'Unidad de Valor Real',
countries: [ 'colombia' ]
}
]
*/
`
`js
import cc from "currency-codes";
console.log(cc.codes());
/*
[
'AED',
'AFN',
...
'ZAR',
'ZMW'
]
*/
`
`js
import cc from "currency-codes";
console.log(cc.numbers());
/*
[
'784',
'971',
...
'710',
'967'
]
*/
`
`js
import cc from "currency-codes";
console.log(cc.countries());
/*
[
'united arab emirates',
'afghanistan',
...
]
*/
`
`js
import data from "currency-codes/data";
console.log(data);
/*
[{
code: 'AED',
number: '784',
digits: 2,
currency: 'United Arab Emirates dirham',
countries: ['united arab emirates']
}, {
code: 'AFN',
number: '971',
digits: 2,
currency: 'Afghan afghani',
countries: ['afghanistan']
}, {
...
*/
`
`js
import cc from "currency-codes";
console.log(cc.publishDate);
/*
2024-06-25
*/
`
Fetch the latest copy of ISO-4217 from the maintainer and update this library's currency data file.
`bash
$ npm run iso
> @winterrdog/currency-codes@2.1.0 iso
> npm run iso:fetch-xml && npm run iso:ingest-xml
> @winterrdog/currency-codes@2.1.0 iso:fetch-xml
> node scripts/fetch-iso-4217-xml.js
Downloaded https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list-one.xml to iso-4217-list-one.xml
> @winterrdog/currency-codes@2.1.0 iso:ingest-xml
> node scripts/ingest-iso-4217-xml.js
Ingested iso-4217-list-one.xml into data.js
Wrote publish date to iso-4217-publish-date.js
``
Note: You may have to manually tweak the capitalization of some country's names.
MIT