6

Some currencies already exist, like [1], [2] and they are all instances of currency [3]. Unfortunately there are no links to all instances from [3]. So is there a possibility to get this list from Wikidata?

2

3 Answers 3

5

Yes, there is.

There are several ways to get this list:

  1. You can, in Wikidata website, look at every entity that has a link to currency (Q8142): https://www.wikidata.org/wiki/Special:WhatLinksHere/Q8142. The problem of this is that you will have some entities that makes a link to currency other than instance of.

  2. The best way is to use an external tool called AutoList, developed by a German guy called Magnus Manske. The link of his tool is here: https://tools.wmflabs.org/autolist/autolist1.html

This tool uses a query language WDQ. Its documentation is here: https://wdq.wmflabs.org/api_documentation.html

Here is how it works:

The property "instance of" has the identifier P31. The value "currency" has the identifier Q8142.

If you want every Wikidata entity with the condition (P31 == Q8142) equals true:

  • copy-paste claim[31:8142] in the form field called Query;
  • click on the Run button.
1
  • 1
    You can also use this link which brings you directly to the results. Commented Nov 7, 2014 at 20:58
3

The official dataset on currencies is maintained by the ISO 4217 standard. You can download the currency dataset in XML or Excel format at this link:

http://www.currency-iso.org/en/home/tables/table-a1.html

2
0

SPARQL query for all currencies ever

Stanislav Kralin gave a good query in the coomments, with some indentation added by me:

select distinct ?currency ?currencyLabel  {
  ?currency wdt:P31/wdt:P279* wd:Q8142
  service wikibase:label  { bd:serviceParam wikibase:language "en" }
}
ORDER BY ?currencyLabel

The constants mean:

  • P31: instance of
  • P279: subclass of
  • Q8142: currency

The way the wdt:P31/wdt:P279* wd:Q8142 pattern works is:

  • find something that is instance of currency
  • or instance of any subclass of currency applied recursively

For example, it could be that Bitcoin is an instance of a cryptocurrency, and cryptocurrency is a subclass of currency. This is not the actual current modeling, just an example.

I've given more details on this question expanding on the "Humans born in New York City" sample query which is analogous: could be born in New York, or born in Brooklyn, or born in some hospital in New York.

Finding only current official currencies of existing countries

The output of the above query, while complete, is likely not the most useful to most people, as it contains all sorts of ancient, experimental, and crypto currencies, many of which don't even have an English wikipedia page and as a result no label.

Here's an initial attempt at getting only current currencies of countries:

SELECT
  ?currency
  (GROUP_CONCAT(DISTINCT ?currencyIsoCode; SEPARATOR=", ") AS ?currencyIsoCodes)
  ?currencyLabel
  (GROUP_CONCAT(DISTINCT ?countryLabel; SEPARATOR=", ") AS ?countries)
WHERE {
  ?country wdt:P31/wdt:P279* wd:Q6256. # is country
  ?country p:P38 ?countryHasCurrency.
  ?countryHasCurrency ps:P38 ?currency.
  ?countryHasCurrency wikibase:rank ?countryHasCurrencyRank.
  OPTIONAL {
    ?currency p:P498 ?currencyHasIsoCode.
    ?currencyHasIsoCode ps:P498 ?currencyIsoCode.
  }
  FILTER NOT EXISTS {?country wdt:P576 ?countryAbolished}
  FILTER NOT EXISTS {?currency wdt:P576 ?currencyAbolished}
  FILTER NOT EXISTS {?currency wdt:P582 ?currencyEndTime}
  FILTER NOT EXISTS {?countryHasCurrency pq:P582 ?countryHasCurrencyEndtime}
  FILTER (?countryHasCurrencyRank != wikibase:DeprecatedRank)
  FILTER (!bound(?currencyHasIsoCode) || ?currencyHasIsoCode != wikibase:DeprecatedRank)
  # TODO makes query take timeout? Why? Needed to exclude PLZ.
  #FILTER NOT EXISTS {?currencyHasIsoCode pq:P582 ?currencyHasIsoCodeEndtime}
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
    ?currency rdfs:label ?currencyLabel .
    ?country rdfs:label ?countryLabel .
  }
}
GROUP BY ?currency ?currencyLabel
ORDER BY ?currencyIsoCodes ?currencyLabel

Sorting by the ISO 4217 code helps tremendously to identify weird currencies that have no ISO code and might be wrong.

The first 3 with empty ISO codes and the first 3 with non-empty ISO codes are:

currency currencyLabel currencyIsoCodes countries
Q131723 bitcoin El Salvador
Q4406 Tuvaluan dollar Tuvalu
Q507737 Cook Islands dollar Cook Islands
Q200294 AED United Arab Emirates dirham United Arab Emirates
Q199471 AFN afghani Afghanistan
Q125999 ALL Albanian lek Albania, Sovereign State of the Bektashi Order

and there is a total of 160 results.

ISO currently has 169 regular country currencies, so we are missing a few, it would be good to understand every single difference and try to fix them.

Some comments on the empty ones that I see:

  • bitcoin: ISO says for El Salvador "El Salvador Colon" (SVC) and "US Dollar" (USD), no Bitcoin yet. I think it is outdated.
  • Faroese króna: so random that it does not have an ISO code
  • Transnistrian ruble: internationally unrecognized territory except for Russia so no ISO
  • Tuvaluan dollar: no ISO
  • Cook Islands dollar: not the currency of Cook Islands anymore since 1995, Wikidata is just missing an end date qualifier.
  • East Timor centavo coins: no ISO
  • Kiribati dollar: no ISO
  • Korean mun: ancient Korean currency discontinued 1892. It has an end date qualifier as the currency of South Korea, I need to update my query to account for that.
  • Niue dollar: not sure, seems to have no ISO
  • Commemorative coins of South Osetia: appears to be just a random specific printing of the coins. Should just be removed as being a currency of South Osetia. Also the state is recognized by very few countries. Should be classified as a commemorative coin instead like many others.
  • SOV: too random no ISO code probably
  • "All-Russian Classifier of Currencies": noise? Seems to be the currency ISO equivalent from Russia, not an actual currency
  • "Irish euro coins": similar issue to "Commemorative coins of South Osetia", a coin and not a currency. It is already marked as a coin and a similar pattern is used for other Euro coins like Latvia, just needs to be removed from currency list of Ireland.

There's also a Wikipedia category for coins without ISO codes.

Basically all country pages are semi-protected on Wikidata so I can't fix them right now.

OK now comparing with ISO with some quick Bash. Currency codes Wikidata missed from ISO:

  • BMD: Bermuda, not a country
  • BOV: MVDOL. Weird inflation adjusted side-currency. A bit like the Chilean Unidad de Fomento Not in the countries currency list, unlike Unidad de Fomento, so does not show on our query.
  • CHE: WIR Euro, weird complementary currency from Switzerland, not in country currencies list
  • CHW: WIR Franc, same
  • COU: Colombian inflation adjusted thing
  • CUC: Cuban convertible peso, now dead and marked as deprecated and so excluded from our query. But ISO still has it. There were other cases were something was excluded and ISO doesn't have it. This is a bad use for deprecation, we should just add end date instead.
  • FKP: Falkland Islands Pound: not a country
  • HKD: Hong Kong Dollar: not a country
  • KYD: Cayman Islands Dollar: not a country
  • MOP: Macao Pataca: not country
  • MXV: Mexican Unidad de Inversion: Mexican inflation adjusted thing
  • SHP: Saint Helena Pound: not country
  • SVC: El Salvador Colon: not in use for some time
  • USN: US Dollar (Next day): what?
  • UYI: Uruguay Peso en Unidades Indexadas (UI): inflation thing
  • UYW: another inflation things from Uruguay
  • VED: some side thing from Venezuela
  • ZWG: Zimbabwe Gold: seems to be the current Zimbabwe one since 2024. Marked as deprecated on country page. Perhaps they have a touch too many currencies in Zimbabwe.

If I try to replace wd:Q6256 (country) with wd:Q56061 (administrative territorial entity) the query times out. This also happens if I try to just get all administrative territorial entity and nothing else, so there must be a billion of them.

Currency codes Wikidata had in excess from ISO at some point in my queries:

  • PLZ: was deprecated in favor of PLN due to inflation, there's an end time on the ISO name
  • SLL: similar case to PLZ, but there was no end to the old one, I need to add it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.