ExodusMovement / coinmarketcap

Price and market capitalization from coinmarketcap.com
MIT License
81 stars 31 forks source link

Feature Request - return available FIAT currencies #5

Closed ghost closed 5 years ago

ghost commented 6 years ago

Hey, I'm using this in a project and it's great.

However, there is no easily accessible list of fiat currencies (the API, v1 and v2) doesn't have this available.

So this is the object I've created, which is currently populated with the available FIAT currencies as per the documentation on the CMC API:

export const supportedFiatCurrencies = [
  {
    code: 'AUD',
    name: 'Australian dollar',
    symbol: '$',
  }, {
    code: 'BRL',
    name: 'Brazilian real',
    symbol: 'R$',
  }, {
    code: 'CAD',
    name: 'Canadian dollar',
    symbol: '$',
  }, {
    code: 'CHF',
    name: 'Swiss franc',
    symbol: 'Fr.',
  }, {
    code: 'CLP',
    name: 'Chilean peso',
    symbol: '$',
    decimals: '0',
  }, {
    code: 'CNY',
    name: 'Chinese yuan',
    symbol: '元',
  }, {
    code: 'CZK',
    name: 'Czech koruna',
    symbol: 'Kč',
  }, {
    code: 'DKK',
    name: 'Danish krone',
    symbol: 'kr.',
  }, {
    code: 'EUR',
    name: 'Euro',
    symbol: '€',
  }, {
    code: 'GBP',
    name: 'Pound sterling',
    symbol: '£',
  }, {
    code: 'HKD',
    name: 'Hong Kong dollar',
    symbol: 'HK$',
  }, {
    code: 'HUF',
    name: 'Hungarian forint',
    symbol: 'Ft',
  }, {
    code: 'IDR',
    name: 'Indonesian rupiah',
    symbol: 'Rp',
  }, {
    code: 'ILS',
    name: 'Israeli new shekel',
    symbol: '₪',
  }, {
    code: 'INR',
    name: 'Indian rupee',
    symbol: '₹',
  }, {
    code: 'JPY',
    name: 'Japanese yen',
    symbol: '¥',
    decimals: '0',
  }, {
    code: 'KRW',
    name: 'South Korean won',
    symbol: '₩',
    decimals: '0',
  }, {
    code: 'MXN',
    name: 'Mexican peso',
    symbol: '$',
  }, {
    code: 'MYR',
    name: 'Malaysian ringgit',
    symbol: 'RM',
  }, {
    code: 'NOK',
    name: 'Norwegian krone',
    symbol: 'kr',
  }, {
    code: 'NZD',
    name: 'New Zealand dollar',
    symbol: '$',
  }, {
    code: 'PHP',
    name: 'Philippine piso',
    symbol: '₱',
  }, {
    code: 'PKR',
    name: 'Pakistani rupee',
    symbol: 'Rs',
  }, {
    code: 'PLN',
    name: 'Polish złoty',
    symbol: 'zł',
  }, {
    code: 'RUB',
    name: 'Russian ruble',
    symbol: '₽',
  }, {
    code: 'SEK',
    name: 'Swedish krona',
    symbol: 'kr',
  }, {
    code: 'SGB',
    name: 'Singapore dollar',
    symbol: 'S$',
  }, {
    code: 'THB',
    name: 'Thai baht',
    symbol: '฿',
  }, {
    code: 'TRY',
    name: 'Turkish lira',
    symbol: '₺',
  }, {
    code: 'TWD',
    name: 'New Taiwan dollar',
    symbol: 'NT$',
  }, {
    code: 'USD',
    name: 'United States dollar',
    symbol: '$',
  }, {
    code: 'ZAR',
    name: 'South African rand',
    symbol: 'R',
  },
];

Using this array of objects one assumes that the currency has 2 decimal places - where the object has a decimals value it should overwrite this (e.g. JPY, CLP, KRW)

The information was taken from the Wikipedia ISO code article.

It could be good to include in this package, would you be interested in me contributing my idea of how it could go in?

Edit: changed currency to name in my application so updated here. Means avoiding currency.currency or const { currency } = currency;

RyanZim commented 6 years ago

I'm not a fan of including static data in this package; if coinmarketcap adds or removes fiat currencies, then we need to stay on top of our game and update the package.

I'd sooner petition CMC to add an API endpoint for this, then query that endpoint from this package.

ghost commented 6 years ago

Thanks, yeah I was thinking so.

On Sat, 28 Jul 2018, 8:32 PM Ryan Zimmerman, notifications@github.com wrote:

I'm not a fan of including static data in this package; if coinmarketcap adds or removes fiat currencies, then we need to stay on top of our game and update the package.

I'd sooner petition CMC to add an API endpoint for this, then query that endpoint from this package.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ExodusMovement/coinmarketcap/issues/5#issuecomment-408608213, or mute the thread https://github.com/notifications/unsubscribe-auth/ATo8k6-KTzg93zRRV0LteEFDxEhxf2gwks5uLGfegaJpZM4Vk3c3 .

ghost commented 6 years ago

I'm contacting coinmarketcap to see if they are interested in incorporating this :)

Maybe we can leave this issue open just for a bit so I can reference them here?

ghost commented 6 years ago

They just released their pro API

https://pro.coinmarketcap.com/

Free tier requires registration.

Good news though, in the free tier they have an endpoint for FIAT conversion!

So they'll be retiring this current API at end of the year.

RyanZim commented 5 years ago

Current API is retired.

tmlee commented 5 years ago

For an open free public API, do consider our offerings at https://www.coingecko.com/api API endpoints are straightforward to consume, and we have some endpoints to solve the problems stated in this issue as well