user5721551
user5721551

Reputation:

get wikidata oldest and latest revision timestamp

Yesterday, I asked a question about how to get wikidata oldest and latest timestamp for "Kevin Kratz (Q939047)", someone suggested using API sandbox to create the query like this:

oldest timestamp: https://www.wikidata.org/w/api.php?action=query&format=json&list=allrevisions&titles=Kevin%20Kratz&arvprop=ids|timestamp|flags|comment|user&arvlimit=1&arvdir=newer

latest timestamp: https://www.wikidata.org/w/api.php?action=query&format=json&list=allrevisions&titles=Kevin%20Kratz&arvprop=ids|timestamp|flags|comment|user&arvlimit=1&arvdir=older

it returned this results: -> oldest timestamp "timestamp": "2004-07-16T02:43:38Z".

-> latest timestamp "timestamp": "2020-03-06T16:33:59Z".

Howerver, after cheking revision history of "Kevin Kratz", I found this (the pic in the end)

After knowing that wikidata was launched in 2012, it made the oldest timestamp value returned by the API sandbox query "2004-07-16T02:43:38Z", irrelevant (latest timestamp from revision history unequal the one from api-sandbox query).

So is there a way to get the latest and oldest timestamp from wikidata revision history?

[1]: https://i.sstatic.net/l3WhK.png

Upvotes: 1

Views: 381

Answers (1)

Pascalco
Pascalco

Reputation: 2826

With list=allrevision you are getting all revisions, not only those of "Kevin Kratz". The oldest revision in Wikidata is from 2004 is because at the beginning of Wikidata some pages were imported from other Wikimedia projects including the revision history.

To get the oldest or newest revision of a particular Wikidata item use prop=revisions. You will have to use the Q-id of the item (Q939047) and not the label (Kevin Kratz) because only the Q-id is unique. The API request to get the oldest revision then reads: https://www.wikidata.org/w/api.php?action=query&format=json&prop=revisions&titles=Q939047&rvprop=ids|timestamp|flags|comment|user&rvlimit=1&rvdir=newer. And for the newest revision: https://www.wikidata.org/w/api.php?action=query&format=json&prop=revisions&titles=Q939047&rvprop=ids|timestamp|flags|comment|user&rvlimit=1&rvdir=older.

Upvotes: 1

Related Questions