I think prop
parameter should have tags
value, like API:RecentChanges.
API talk:Compare
Can this api do that job (to get inline diff)?
Code in back-end shows that it's possible to change the type of diff to inline, but this API can't do that.
Now (2024), this API had inline diff type.
either API or special:comparepage
thanks.
try to put fqdn of two pages (off two sites in a family), it doesn't come up with anything.
anyone knows if this is possible?
I'm interested in this as well. I've posted a similar question on Stackoverflow: https://stackoverflow.com/questions/68814626/is-there-a-possibility-in-mediawiki-to-have-a-diff-of-different-pages-on-interwi
Or if there is another way to do it?
I've tried the sample javascript code on the API page but it returns
Uncaught ReferenceError: request is not defined
I tried requiring the request, but it just tells me the requirement is not defined. Can someone help please?
Also interested in methods using the replicas on Wikimedia Toolforge, although I don't think that route is possible.
You can ask for a relative comparison to prev
at the first revision of a page:
https://en.wikipedia.org/w/api.php?action=compare&fromrev=14189795&torelative=prev
This will result in the full text of the first revision being returned as the diff. Note that this is not accurate, since in some cases there may be default content for the page before its first revision. The fromrevid
property will be absent from the results.
Similarly, you can ask for the next
relative comparison on the last revision of a page:
https://en.wikipedia.org/w/api.php?action=compare&fromrev=874792395&torelative=next
(Note: this is the last revision as of the writing of this topic. Because the page is protected, it probably should not change.) The result is an empty diff, and the torevid
will be absent. Unlike most revision comparisons, these results will change if a new revision is created.
This behaviour in the API is historical. It isn't consistent with the conceptual model of page history as a series of revisions. There is no "previous" revision to compare against the first revision, nor is there a "next" revision to compare against the last. Because of this, future versions of MediaWiki may give different results for this API call.
Does anyone know how to retrieve the very first diff of a wikibase-item (Wikidata item) using action=compare
, i.e. the diff of the item creation? fromrev=0
does not work, and I don’t manage to find a way with fromtext
(and fromcontentmodel
and fromcontentformat
; non-functional example: ).
My question was answered here at Wikidata, in case anyone is interested.
When included in the query I'm getting this warning: "Unrecognized parameter: prop."
You've probably got a lower version of MediaWiki. That was only added very recently. I've updated the version numbers on the page to make it easier to tell.