What is currency-codes?
The currency-codes npm package provides a comprehensive list of currency codes and related information based on the ISO 4217 standard. It allows users to look up currency codes, names, and other related data.
What are currency-codes's main functionalities?
Get currency by code
This feature allows you to retrieve information about a currency using its code. For example, 'USD' will return details about the US Dollar.
const currencyCodes = require('currency-codes');
const currency = currencyCodes.code('USD');
console.log(currency);
Get currency by number
This feature allows you to retrieve information about a currency using its numeric code. For example, '840' will return details about the US Dollar.
const currencyCodes = require('currency-codes');
const currency = currencyCodes.number('840');
console.log(currency);
Get currency by countries
This feature allows you to retrieve a list of currencies used in a specific country. For example, 'United States' will return the US Dollar.
const currencyCodes = require('currency-codes');
const currencies = currencyCodes.countries('United States');
console.log(currencies);
Get all currency codes
This feature allows you to retrieve a list of all currency codes available in the package.
const currencyCodes = require('currency-codes');
const allCurrencies = currencyCodes.codes();
console.log(allCurrencies);
Other packages similar to currency-codes
iso-currency
The iso-currency package provides similar functionality to currency-codes, offering ISO 4217 currency codes and related information. It allows for lookups by code, number, and country, similar to currency-codes.
currency-formatter
The currency-formatter package focuses on formatting currency values but also includes currency code information. It is useful if you need both currency code data and formatting capabilities.
currency-symbol-map
The currency-symbol-map package provides a mapping of currency codes to their symbols. While it does not offer as comprehensive data as currency-codes, it is useful for quickly retrieving currency symbols.
currency-codes
A node.js module to list and work on currency codes based on the ISO 4217 standard.
npm install currency-codes
code('EUR')
var cc = require('currency-codes');
console.log(cc.code('EUR'));
number(967)
var cc = require('currency-codes');
console.log(cc.number(967));
country('colombia')
var cc = require('currency-codes');
console.log(cc.country('colombia'));
codes()
var cc = require('currency-codes');
console.log(cc.codes());
numbers()
var cc = require('currency-codes');
console.log(cc.numbers());
countries()
var cc = require('currency-codes');
console.log(cc.countries());
data
var data = require('currency-codes/data');
console.log(data);
publishDate
var cc = require('currency-codes');
console.log(cc.publishDate);
Updating the data
Fetch the latest copy of ISO-4217 from the maintainer and update this library's currency data file.
$ npm run iso
> currency-codes@2.1.0 iso
> npm run iso:fetch-xml && npm run iso:ingest-xml
> 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
> 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.
License
MIT