SUMMARY The converter tool in Krunner works with some currencies (like EUR or USD), but not with some others. At least TWD/NTD (taiwanese dollar) and VND (vietnamese dong) are not available. STEPS TO REPRODUCE 1. open Krunner 2. type "1eur to ntd" or "1eur to vnd" OBSERVED RESULT nothing EXPECTED RESULT the value of 1€ in ntd or vnd SOFTWARE/OS VERSIONS Linux/KDE Plasma: (available in About System) KDE Plasma Version: 5.19.5 KDE Frameworks Version: 5.74.0 Qt Version: 5.15.1 ADDITIONAL INFORMATION
The currencies are fetched from https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml. And these currencies are not contained in the xml file.
We would need to use a different API to fetch these currencies. TBH this can be really controversial in regards to privacy reasons. But if you have a suggestion I am happy to hear :)
I looked up existing existing free APIs (that do not require identification). Most Central Banks seem to have one that provides conversion rates between their country's money and Euro/USD or a small number of currencies. I guess it is possible to call to all those APIs and merge the results. It might not be practical, but I didn't find any freely accessible API regrouping more currencies than the ECB one.
Some free APIs may have limitations, e.g. commercial use disallowed. It looks like libqalculate uses www.mycurrency.net as one of the sources, [1] but the website has no privacy policy. [1] https://github.com/Qalculate/libqalculate/blob/e7b7726493aa2a09d39a1497d0195fb60cc3052f/libqalculate/Calculator-definitions.cc#L3786
Update, after more research I found more APIs: - exchangerate-api.com provides a free API with 52 currencies supported (that's 20 more than the ECB). They have terms of service that seem ok to use (but I'm not a specialist). They also have rate limitations, which I am not sure whether they would affect usage in KRunner or not. - fixer.io explicitly says they support non-profits and we can contact them to find an agreement. They support 170 currencies. - the UN seems to have an API (https://treasury.un.org/operationalrates/OperationalRates.php) but terms say it is intended for internal use, I am not sure if that allows external use. - The OECD has data for many countries (https://stats.oecd.org/Index.aspx?DataSetCode=SNA_TABLE4) but I didn't find a way to access it via an API, even though a document from 2013 said they should have one. - Eurostats has data about most european currencies, plus 4 extra-European including USD. The database name is teimf200, so the URL will look like https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/teimf200 , and documentation about how to use it is available at https://ec.europa.eu/eurostat/web/json-and-unicode-web-services/getting-started/rest-request - Finally the World Bank has an API that is almost complete, but provides average over periods of time rather than instant exchange rate (that may not be a problem in our case). Site: https://datacatalog.worldbank.org, API use example: https://api.worldbank.org/v2/en/country/all/indicator/PA.NUS.FCRF?date=2019&format=json&per_page=20000&source=2 . Also, they only give the country codes, not currency codes. And they also skip Taiwan's currency, probably because it's not recognised as a country. It is probably possible to get a little bit of several free APIs, or get an agreement with fixer.io to access their data.
(In reply to skrachen from comment #5) - The UN Rates skip Taiwan for obvious reasons. It is not a good choice because the rates are not market rates [1]. - Same for OECD (skips Taiwan, rates are not market rates). - Eurostats' teimf200 is "monthly average - not seasonally adjusted", as can be seen in the JSON data returned. In other words, the rates are not current market rates. - As mentioned, World Bank is also not suitable. [1] https://treasury.un.org/operationalrates/default.php ----- ----- ----- ----- ----- For fixer.io and exchangerate-api.com, we need to check the limitations as well as their privacy policies. By the way, fixer.io's free plan does not support SSL.
*** Bug 401158 has been marked as a duplicate of this bug. ***
update after some research: I found 2 open-source apps that do currency conversion: - moneta (github.com/matfantinel/moneta) that uses a custom API, which source code I could not find - KEuroCalc (github.com/KDE/keurocalc/blob/master/currencies/currencies.cpp) which uses the ECB API, plus timegenie API (https://rss.timegenie.com/forex2.xml). Timegenie API seems to work well and has many currencies, but I couldn't find any copyright or privacy policy statement on their site. Some Central Banks provide exchange rates through APIs: - Taiwan: ECB data + Taiwanese and vietnamese currencies (https://rate.bot.com.tw/xrt/fltxt/0/day) - Vietnam: ECB data + Vietnamese, saudi and kuwaiti currencies (https://portal.vietcombank.com.vn/Usercontrols/TVPortal.TyGia/pXML.aspx?b=68) - Israel: there are a few middle eastern currencies missing from the ECB (https://www.boi.org.il/currency.xml?rdate=20210412) With only currencies that are already available through the ECB API: - Brazil: https://opendata.bcb.gov.br/dataset/exchange-rates-daily-bulletins
update after email sending to contact addresses of foreignexchangeresource.com and exchangerate-api.com: exchangerate-api.com said they have an open API endpoint that doesn't require any key, has daily updates and no limits on the number of requests (though rate seems to be limited). The documentation of this API is at exchangerate-api.com/docs/free , and their privacy policy at exchangerate-api.com/terms . foreignexchangeresource.com was made by an independent developer who said he uses these APIs to get the data: http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml http://www.bankofcanada.ca/valet/fx_rss/ http://www.boi.org.il/currency.xml http://forex.cbm.gov.mm/api/latest (Seems to be down now. I actually haven't checked in some time)(could be due to the current coup in Myanmar) http://www.nbp.pl/kursy/xml/LastA.xml https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange https://poloniex.com/public?command=returnTicker (Crypto)
Thanks for the research. I will look into the options you presented.
Found another API (from the Swiss government), which contains 75 currencies: https://www.backend-rates.bazg.admin.ch/api/xmldaily
(In reply to Alexander Lohnau from comment #2) > We would need to use a different API to fetch these currencies. TBH this can > be really controversial in regards to privacy reasons. But if you have a > suggestion I am happy to hear :) Hello, actually, I was just about to open a new bug report regarding this issue. Then i came across this thread... The following exchange API might be useful. Please check it out: https://openexchangerates.org/ Thanks, Koray