If you're familiar with SQL, you shouldn't have a hard time understanding SPARQL: here 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&prop=linkshere&format=json

After this I have to call for each result:
https://www.wikidata.org/w/api.php?action=wbgetentities&props=labels&ids=Q21&languages=en

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@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api