If you're familiar with SQL, you shouldn't have a hard time
understanding SPARQL: here
<https://query.wikidata.org/#PREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0A%0ASELECT%20%3FwikidataId%20%3Fcode%20%3FwikidataIdLabel%20WHERE%20%7B%0A%20%20%3FwikidataId%20wdt%3AP300%20%3Fcode%20.%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20.%0A%20%20%7D%0A%7D>
is a query you may find useful.
Il 14/01/2016 19:09, Sven Anders ha scritto:
Hi,
for the OSM-Validatior of the "Open Diplomatic Map" [1] I would
like to a get a list of all ISO 3166-2 Codes (P300) in a "table".
In SQL I would do:
SELECT p.value, q.label.en, q.id FROM Q q, P p WHERE p='P300' AND p in q
That should result in:
[{'code':'GB-ENG', 'label-en':'England',
'wikidataId':'Q21'},
{'code':'GB-SCT', 'label-en':'Scotland',
'wikidataId':'Q22'},
...
]
How do I get the data best. I saw that there is an API-call:
https://www.wikidata.org/w/api.php?action=query&titles=Property:P300&am…
After this I have to call for each result:
https://www.wikidata.org/w/api.php?action=wbgetentities&props=labels&am…
I hope there is a better way to do this?
Best Regards
Sven
1:
https://anders.hamburg/osm/diplomatic/
_______________________________________________
Mediawiki-api mailing list
Mediawiki-api(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api