How to get page ID from wiki data API using SPARQL

130 Views Asked by At

With the following query I get all the tourist attractions near me with SPARQL using the Wiki Data API. What I can't get to work is: I also need the page ID for each result. The page ID is the unique ID that an article has on every wikipedia page. Example: https://en.wikipedia.org/wiki/Big_Ben has page ID: 7290308 in the english wikipedia.

SELECT DISTINCT ?item ?itemLabel ?image ?itemCoordinates ?description ?wikipediaLink ?wikipediaID WHERE {
  SERVICE wikibase:around {
    ?item wdt:P625 ?itemCoordinates .
    bd:serviceParam wikibase:center "Point(9.2478 48.9929)"^^geo:wktLiteral .
    bd:serviceParam wikibase:radius "5" .
  }
 FILTER (
  EXISTS { ?item wdt:P31/wdt:P279* wd:Q570116 } # Tourist attractions
)
  OPTIONAL { ?item wdt:P18 ?image }
  OPTIONAL {
    ?item schema:description ?description .
    FILTER(LANG(?description) = "de")
  }
  OPTIONAL {
    ?wikipediaLink schema:about ?item ;
                   schema:isPartOf <https://de.wikipedia.org/> .
  }
  FILTER EXISTS { 
    ?wikipediaLink schema:about ?item ;
                   schema:isPartOf <https://de.wikipedia.org/> .
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
LIMIT 100
OFFSET 0

How do I get the page ID? The URL is good but doesn't include the ID..

0

There are 0 best solutions below