function getDiff( pageName, pageContent ) { var api = new mw.Api(); return api.post( { action: 'query', prop: 'revisions', rvprop: 'content', rvlimit: '1', titles: pageName, rvdifftotext: pageContent } ).then( function ( data ) { var obj; for ( var page in data.query.pages ) { obj = data.query.pages[ page ]; } var diff; if ( obj !== undefined ) { diff = obj.revisions[ 0 ].diff[ '*' ]; } return diff; } ); }
Deprecated since MW 1.30; rMWf389d14b383f: API: Deprecate diff and parse parameters in ApiQueryRevisionsBase.
{ "batchcomplete": "", "warnings": { "main": { "*": "Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application." }, "revisions": { "*": "The parameter \"rvdifftotext\" has been deprecated.\nBecause \"rvslots\" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used." } } }
That warning is probably not the most helpful; we really don't just want to pass rvslots.
If we look at https://www.mediawiki.org/w/api.php?action=help&modules=query%2Brevisions
rvdifftotext Deprecated. Use action=compare instead. Text to diff each revision to. Only diffs a limited number of revisions. Overrides rvdiffto. If rvsection is set, only that section will be diffed against this text.
action=compare should probably be used instead. It has existed since rMWc8079f0b81fe: * (bug 27185) API: Add Special:ComparePages in T29185: API: Add Special:ComparePages from 2011, so shouldn't be any issues with MLEB back compat etc.