Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I query Wikidata for items modified in the last day?

I am trying to retrieve all wikidata items within a latitude/longitude bounding box that have been edited in the last 24 hours

I get through the bounding box part ok, but I can't figure the "modified since" bit.

This is the closest example I could find, from which I tried to make this work:

SELECT ?place WHERE {
  SERVICE wikibase:box {
    ?place wdt:P625 ?location .
    # looks like cornerwest must be south of cornereast
    # otherwise you go around the globe
    # this is lng lat
    bd:serviceParam wikibase:cornerWest "Point(SW_LNG SW_LAT)"^^geo:wktLiteral .
    bd:serviceParam wikibase:cornerEast "Point(NE_LNG NE_LAT)"^^geo:wktLiteral .
  }
  ?place wdt:P31  ?placeCategory .
  ?place wdt:P625 ?placeCoords   .

  optional{ ?place wdt:P18 ?placePicture . }


  BIND (now() - ?modified as ?date_range)
  FILTER (?date_range > 2)
}

without results.

like image 569
simone Avatar asked Sep 14 '25 14:09

simone


1 Answers

Use schema:dateModified. By the way, Blazegraph supports date and time arithmetic:

SELECT ?place ?placeLabel ?location WHERE {
  BIND ((now() - "P7D"^^xsd:duration) AS ?date_)
  SERVICE wikibase:box {
    ?place wdt:P625 ?location   .
    bd:serviceParam wikibase:cornerSouthWest "Point(55.000 55.000)"^^geo:wktLiteral.
    bd:serviceParam wikibase:cornerNorthEast "Point(65.000 65.000)"^^geo:wktLiteral.
  }
  ?place schema:dateModified ?date .
  # hint:Prior hint:rangeSafe true .
  FILTER (?date >= ?date_)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "ru". }
}

https://w.wiki/3E9Z

There is also the wikibase:timestamp predicate which is rather auxiliary.

like image 60
Stanislav Kralin Avatar answered Sep 17 '25 20:09

Stanislav Kralin