0

Is there a way to access wikidata revision history page using SPARQL or wikimedia-API for the Item Eden Hazard (Q214204) as an example, to get the latest and oldest timestamps values?

Jeevitha
  • 121
  • 8
  • 2
    Does this answer your question? [get wikidata first and last revision timestamp](https://stackoverflow.com/questions/60567772/get-wikidata-first-and-last-revision-timestamp) – Stanislav Kralin Mar 09 '20 at 11:04
  • @StanislavKralin when I used the aswer to https://stackoverflow.com/questions/60567772/get-wikidata-first-and-last-revision-timestamp , first timestamp revision was before wikidata was even launched ```first timestamp: "timestamp": "2004-07-16T02:43:38Z" ``` while wikidata was launched en 2012!! –  Mar 09 '20 at 12:13
  • on history endpoint: `PREFIX rdf: PREFIX rdfs: PREFIX schema: PREFIX wd: PREFIX wdt: PREFIX hist: select distinct ?s ?date { ?s schema:about wd:Q939047 ; schema:dateCreated ?date filter(?date = ?last || ?date = ?first) { select (min(?date) as ?first) (max(?date) as ?last) { ?s schema:about wd:Q939047; schema:dateCreated ?date} } }` – UninformedUser Mar 09 '20 at 15:57
  • @UninformedUser it returned: "no matching records found" and I used wikidata query service https://query.wikidata.org/ –  Mar 10 '20 at 10:35
  • and I said *"on history endpoint"* ... https://wdhqs.wmflabs.org/ – UninformedUser Mar 10 '20 at 12:22
  • to get the revisions with the Wikimedia API, see https://stackoverflow.com/questions/60577244/get-wikidata-oldest-and-latest-revision-timestamp – Pascalco Mar 25 '20 at 20:10

2 Answers2

0

There’s a fun way to access mediawiki data that happens to be excellent for such metadata: https://quarry.wmflabs.org

Set the database to wikidatawiki_p. Here‘s the SQL:

SELECT MAX(rev_timestamp), MIN(rev_timestamp) 
FROM page JOIN revision 
ON page.page_id = revision.rev_page 
WHERE page_title = "Q214204";

I’ve published the query here: https://quarry.wmflabs.org/query/57342

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
Matthias Winkelmann
  • 15,870
  • 7
  • 64
  • 76
0

Answers above have described how to get the timestamps of older versions of a Wikidata object. To get the contents of an older version of the wikidata-object you can use the [enter link description here][MediaWiki Revisions API].

The following query gives you the contents of two named revisions of Q42175289

https://www.wikidata.org/w/api.php?action=query&format=json&formatversion=2&prop=revisions&revids=580231008|580231017&rvprop=timestamp|comment|content&rvslots=main

whereas the following gives you the first 3 revisions of the same item (with contents)

https://www.wikidata.org/w/api.php?action=query&format=json&prop=revisions&titles=Q42175289&formatversion=2&rvprop=ids%7Ccomment%7Ccontent%7Ccontentmodel&rvslots=main&rvlimit=3&rvdir=newer

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
Lokal_Profil
  • 384
  • 1
  • 13
  • For those, like me, who originally found this post because they wanted to work with Structured Data on Wikimedia Commons. Note that you need to replace `rvslots=main` by `rvslots=mediainfo`. – Lokal_Profil Nov 24 '22 at 11:27