I'm working on a map render application and I would need to have the relation ID of OpenStreetMap from the Wikidata ID in order to download the GeoJSON file.
I have made some search and found a good way, but not perfect:
- Get Wikidata ID (eg:Q183)
- Query the Wikidata API with the ID(eg:https://www.wikidata.org/w/api.php?action=wbgetentities&format=json&ids=Q183)
- Get the relation ID from the field P402 : (eg:entities[Q183].claims.P402[0].mainsnak.datavalue.value)
- Query the OpenStreetMap Polygon API to get the JSON File (eg:http://polygons.openstreetmap.fr/get_geojson.py?id=51477)
It works great, but for a lot of cities the Wikidata API (step 3) doesn't return the Relation ID, but on the OpenStreetMap page of the city the Wikidata ID is present, so there is the link.
I would like to know if there is a way to get the Relation ID from the Wikidata ID on the OpenStreetMap API?