API:Compare
From MediaWiki.org
| This page is part of the MediaWiki action API documentation. |
MediaWiki action API
- Introduction and quick start
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Searching (by title, content, coordinates...)
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
- Asserting
| Compare | ||
|---|---|---|
| Get the difference between 2 pages. This module cannot be used as a Generator. |
||
| Prefix | none | |
| Required rights | none | |
| Post only? | No | |
| Generated help | Current | |
| Version added |
|
Get the difference between two pages.
A revision number, a page title, or a page ID for both "from" and "to" must be passed.
Parameters[edit]
fromtitle: First title to compare.fromid: First page ID to compare. 1.20+fromrev: First revision to compare.totitle: Second title to compare.toid: Second page ID to compare. 1.20+torev: Second revision to compare.
Example[edit]
Compare two revisions from the same page
| Result |
|---|
{
"compare": {
"fromrevid": 139992,
"torevid": 139993,
"*": "<tr>\n <td colspan=\"2\" class=\"diff-lineno\">Line 26:</td>\n <td colspan=\"2\" class=\"diff-lineno\">Line 26:</td>\n</tr>\n<tr>\n <td class=\"diff-marker\"> </td>\n <td class=\"diff-context\"></td>\n <td class=\"diff-marker\"> </td>\n <td class=\"diff-context\"></td>\n</tr>\n<tr>\n <td class=\"diff-marker\"> </td>\n <td class=\"diff-context\"><div>:'''Wikipedias in other languages'''</div></td>\n <td class=\"diff-marker\"> </td>\n <td class=\"diff-context\"><div>:'''Wikipedias in other languages'''</div></td>\n</tr>\n<tr>\n <td class=\"diff-marker\">\u2212</td>\n <td class=\"diff-deletedline\"><div>:[[Non-English Wikipedias|About the non-English Wikipedias]] - [http://af.wikipedia.com/ Afrikaans] - [http://ar.wikipedia.com/ Arabic (Araby)] - [http://eu.wikipedia.com/ Basque (Euskara)] - [http://ca.wikipedia.com/ Catalan (<del class=\"diffchange diffchange-inline\">Catal\u00e0</del>)] - [http://zh.wikipedia.com/ Chinese (Hanyu)] - [http://dk.wikipedia.com/ Danish (Dansk)] - [http://nl.wikipedia.com/ Dutch (Nederlands)] - [http://eo.wikipedia.com/ Esperanto] - [http://fr.wikipedia.com/ French (<del class=\"diffchange diffchange-inline\">Fran\u00e7ais</del>)] - [http://de.wikipedia.com/ German (Deutsch)] - [http://he.wikipedia.com/ Hebrew (Ivrit)] - [http://hu.wikipedia.com/ Hungarian (Magyar)] - [http://it.wikipedia.com/ Italian (Italiano)] - [http://ja.wikipedia.com/ Japanese (Nihongo)] - [http://no.wikipedia.com/ Norwegian (Norsk)] - [http://pl.wikipedia.com/ Polish (Polska)] - [http://pt.wikipedia.com/ Portuguese (<del class=\"diffchange diffchange-inline\">Portugu\u00eas</del>)] - [http://ru.wikipedia.com/ Russian (Russkiy)] - [http://sh.wikipedia.com/ Serbocroatian (Croatoserbian)] - [http://es.wikipedia.com/ Spanish (Castellano)] - [http://sv.wikipedia.com/ Swedish (Svensk)] </div></td>\n <td class=\"diff-marker\">+</td>\n <td class=\"diff-addedline\"><div>:[[Non-English Wikipedias|About the non-English Wikipedias]] - [http://af.wikipedia.com/ Afrikaans] - [http://ar.wikipedia.com/ Arabic (Araby)] - [http://eu.wikipedia.com/ Basque (Euskara)] - [http://ca.wikipedia.com/ Catalan (<ins class=\"diffchange diffchange-inline\">Catal&agrave;</ins>)] - [http://zh.wikipedia.com/ Chinese (Hanyu)] - [http://dk.wikipedia.com/ Danish (Dansk)] - [http://nl.wikipedia.com/ Dutch (Nederlands)] - [http://eo.wikipedia.com/ Esperanto] - [http://fr.wikipedia.com/ French (<ins class=\"diffchange diffchange-inline\">Fran&ccedil;ais</ins>)] - [http://de.wikipedia.com/ German (Deutsch)] - [http://he.wikipedia.com/ Hebrew (Ivrit)] - [http://hu.wikipedia.com/ Hungarian (Magyar)] - [http://it.wikipedia.com/ Italian (Italiano)] - [http://ja.wikipedia.com/ Japanese (Nihongo)] - [http://no.wikipedia.com/ Norwegian (Norsk)] - [http://pl.wikipedia.com/ Polish (Polska)] - [http://pt.wikipedia.com/ Portuguese (<ins class=\"diffchange diffchange-inline\">Portug&ecirc;s</ins>)] - [http://ru.wikipedia.com/ Russian (Russkiy)] - [http://sh.wikipedia.com/ Serbocroatian (Croatoserbian)] - [http://es.wikipedia.com/ Spanish (Castellano)] - [http://sv.wikipedia.com/ Swedish (Svensk)] </div></td>\n</tr>\n<tr>\n <td class=\"diff-marker\"> </td>\n <td class=\"diff-context\"><div>----</div></td>\n <td class=\"diff-marker\"> </td>\n <td class=\"diff-context\"><div>----</div></td>\n</tr>\n<tr>\n <td class=\"diff-marker\"> </td>\n <td class=\"diff-context\"><div>:'''Wikipedia'''</div></td>\n <td class=\"diff-marker\"> </td>\n <td class=\"diff-context\"><div>:'''Wikipedia'''</div></td>\n</tr>\n"
}
}
|
Compare the current revisions of two different pages
| Result |
|---|
{
"compare": {
"fromtitle": "Template:Unsigned",
"fromrevid": 645069201,
"totitle": "Template:UnsignedIP",
"torevid": 438827460,
"*": "<tr>\n <td colspan=\"2\" class=\"diff-lineno\">Line 1:</td>\n <td colspan=\"2\" class=\"diff-lineno\">Line 1:</td>\n</tr>\n<tr>\n <td class=\"diff-marker\">\u2212</td>\n <td class=\"diff-deletedline\"><div><del class=\"diffchange diffchange-inline\"><small><span class=\"autosigned\">\u2014&nbsp;Preceding</del> [[<del class=\"diffchange diffchange-inline\">Wikipedia</del>:<del class=\"diffchange diffchange-inline\">Signatures|unsigned]]</del> <del class=\"diffchange diffchange-inline\">comment added by [[User:{{{1}}}|{{{1}}}</del>]]<del class=\"diffchange diffchange-inline\"> ([[User talk:{{{1}}}|talk]] \u2022 [[Special:Contributions/{{{1}}}|contribs]]) {{{2|}}}</span></small><!-- Template:Unsigned --><noinclude></del></div></td>\n <td class=\"diff-marker\">+</td>\n <td class=\"diff-addedline\"><div><ins class=\"diffchange diffchange-inline\">#REDIRECT</ins> [[<ins class=\"diffchange diffchange-inline\">Template</ins>:<ins class=\"diffchange diffchange-inline\">Unsigned</ins> <ins class=\"diffchange diffchange-inline\">IP</ins>]]</div></td>\n</tr>\n<tr>\n <td class=\"diff-marker\">\u2212</td>\n <td class=\"diff-deletedline\"><div>{{documentation}} <!-- add categories to the /doc page, not here --></noinclude></div></td>\n <td colspan=\"2\" class=\"diff-empty\"> </td>\n</tr>\n"
}
}
|
| The following documentation is the output of Special:ApiHelp/compare, generated from compare's source code. |
action=compare
(main | compare)
- This module requires read rights.
- Source: MediaWiki
- License: GPL-2.0+
Get the difference between 2 pages.
A revision number, a page title, or a page ID for both "from" and "to" must be passed.
Parameters:
- fromtitle
-
First title to compare.
- fromid
-
First page ID to compare.
- Type: integer
- fromrev
-
First revision to compare.
- Type: integer
- totitle
-
Second title to compare.
- toid
-
Second page ID to compare.
- Type: integer
- torev
-
Second revision to compare.
- Type: integer
Example:
- Create a diff between revision 1 and 2.
- api.php?action=compare&fromrev=1&torev=2 [open in sandbox]

