API:Revisions/fr

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page API:Revisions and the translation is 6% complete.

Other languages:
English • ‎dansk • ‎español • ‎français • ‎italiano • ‎日本語
Version de MediaWiki : 1.8

GET request to obtain revision information of page(s).

API documentation




prop=revisions (rv)

(main | query | revisions)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Get revision information.

May be used in several ways:

  1. Get data about a set of pages (last revision), by setting titles or pageids.
  2. Get revisions for one given page, by using titles or pageids with start, end, or limit.
  3. Get data about a set of revisions by setting their IDs with revids.
Parameters:
rvprop

Which properties to get for each revision:

ids
The ID of the revision.
flags
Revision flags (minor).
timestamp
The timestamp of the revision.
user
User that made the revision.
userid
User ID of the revision creator.
size
Length (bytes) of the revision.
slotsize
Length (bytes) of each revision slot.
sha1
SHA-1 (base 16) of the revision.
slotsha1
SHA-1 (base 16) of each revision slot.
contentmodel
Content model ID of each revision slot.
comment
Comment by the user for the revision.
parsedcomment
Parsed comment by the user for the revision.
content
Content of each revision slot.
tags
Tags for the revision.
roles
List content slot roles that exist in the revision.
parsetree
Deprecated. Use action=expandtemplates or action=parse instead. The XML parse tree of revision content (requires content model wikitext).
Values (separate with | or alternative): ids, flags, timestamp, user, userid, size, slotsize, sha1, slotsha1, contentmodel, comment, parsedcomment, content, tags, roles, parsetree
Default: ids|timestamp|flags|comment|user
rvslots

Which revision slots to return data for, when slot-related properties are included in rvprops. If omitted, data from the main slot will be returned in a backwards-compatible format.

Values (separate with | or alternative): main
To specify all values, use *.
rvlimit

Limit how many revisions will be returned.

May only be used with a single page (mode #2).
No more than 500 (5,000 for bots) allowed.
Type: integer or max
rvexpandtemplates
Deprecated.

Use action=expandtemplates instead. Expand templates in revision content (requires rvprop=content).

Type: boolean (details)
rvgeneratexml
Deprecated.

Use action=expandtemplates or action=parse instead. Generate XML parse tree for revision content (requires rvprop=content).

Type: boolean (details)
rvparse
Deprecated.

Use action=parse instead. Parse revision content (requires rvprop=content). For performance reasons, if this option is used, rvlimit is enforced to 1.

Type: boolean (details)
rvsection

Only retrieve the content of this section number.

rvdiffto
Deprecated.

Use action=compare instead. Revision ID to diff each revision to. Use prev, next and cur for the previous, next and current revision respectively.

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.

rvdifftotextpst
Deprecated.

Use action=compare instead. Perform a pre-save transform on the text before diffing it. Only valid when used with rvdifftotext.

Type: boolean (details)
rvcontentformat
Deprecated.

Serialization format used for rvdifftotext and expected for output of content.

One of the following values: application/json, text/css, text/plain, text/x-wiki, text/javascript
rvstartid

Start enumeration from this revision's timestamp. The revision must exist, but need not belong to this page.

May only be used with a single page (mode #2).
Type: integer
rvendid

Stop enumeration at this revision's timestamp. The revision must exist, but need not belong to this page.

May only be used with a single page (mode #2).
Type: integer
rvstart

From which revision timestamp to start enumeration.

May only be used with a single page (mode #2).
Type: timestamp (allowed formats)
rvend

Enumerate up to this timestamp.

May only be used with a single page (mode #2).
Type: timestamp (allowed formats)
rvdir

In which direction to enumerate:

newer
List oldest first. Note: rvstart has to be before rvend.
older
List newest first (default). Note: rvstart has to be later than rvend.
May only be used with a single page (mode #2).
One of the following values: newer, older
Default: older
rvuser

Only include revisions made by user.

May only be used with a single page (mode #2).
Type: user name
rvexcludeuser

Exclude revisions made by user.

May only be used with a single page (mode #2).
Type: user name
rvtag

Only list revisions tagged with this tag.

rvtoken
Deprecated.

Which tokens to obtain for each revision.

Values (separate with | or alternative): rollback
rvcontinue

When more results are available, use this to continue.

Examples

Example 1: Get revision data of several pages

GET request

Request above is to obtain revision data of pages with titles API and Main Page

Réponse

Sample Code

get_pages_revisions.py

#!/usr/bin/python3

"""
    get_pages_revisions.py
    MediaWiki Action API Code Samples
    Demo of `Revisions` module: Get revision data with content for pages
    with titles [[API]] and [[Main Page]]
    MIT License
"""

import requests

S = requests.Session()

URL = "https://mediawiki.org/w/api.php"

PARAMS = {
    "action": "query",
    "prop": "revisions",
    "titles": "API|Main Page",
    "rvprop": "timestamp|user|comment|content",
    "rvslots": "main",
    "formatversion": "2",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS)
DATA = R.json()

print(DATA)

Example 2: Get last five revisions of a page filtered by date and user

GET request

Request above is to obtain data for the last five revisions of the page API:Geosearch made after the 1st of July 2018, i.e. 2018-07-01 excluding changes made by the user SSethi (WMF)

Réponse

Sample Code

Possible errors

Code Info
rvdiffto rvdiffto must be set to "prev", "next", "cur" or a non-negative number.
rvnosuchrevid There is no revision with ID ID
rvnosuchsection There is no section section in rID
rvrevids The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).
rvmultpages titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.
rvaccessdenied The current user is not allowed to read title
rvbadparams start and startid cannot be used together
rvbadparams end and endid cannot be used together
rvbadparams user and excludeuser cannot be used together
invalidparammix titles, pageids ou un générateur a été utilisé pour fournir plusieurs pages, mais les paramètres rvlimit, rvstartid, rvendid, rvdir=newer, rvuser, rvexcludeuser, rvstart et rvend ne peuvent être utilisés que sur une seule page.
accessdenied Vous n’êtes pas autorisé à voir title.
badid_startid Pas de correction trouvée pour le paramètre startid.
badid_endid Pas de correction trouvée pour le paramètre endid.

Additional notes

  • Pages are specified either by pageids or titles parameter. Individual revisions are specified by revids parameter. See <tvar|1>API:Query#Specifying pages .
  • Slots can be specified with the rvslots parameter. When the parameter is not present, the API will only return information about the main slot.
  • When using parameters marked as (enum), titles= must have only one title listed.
  • This module couldn't be used a generated prior to version 1.25.
  • Diff functionality of this module was deprecated in version 1.30 and got moved to API:Comparer .
  • The code for this query is located on the git repository at ApiQueryRevisions.php.

Parameter History

  • v1.32: Introduced rvslots,roles Deprecated rvcontentformat
  • v1.30: Deprecated parsetree,rvprop,rvexpandtemplates,rvparse,rvdiffto,rvdifftotext,rvdifftotextpst
  • v1.27: Introduced rvdifftotextpst
  • v1.26: Introduced parsetree Deprecated rvgeneratexml
  • v1.24: Deprecated rvtoken
  • v1.21: Introduced contentmodel,rvcontentformat
  • v1.19: Introduced sha1,rvparse
  • v1.17: Introduced userid,rvparse
  • v1.16: Introduced parsedcomment,tags,rvdifftotext,rvtag
  • v1.15: Introduced rvdiffto,rvcontinue
  • v1.14: Introduced rvgeneratexml
  • v1.13: Introduced rvsection
  • v1.12: Introduced rvexpandtemplates,rvtoken
  • v1.11: Introduced ids,flags,size,rvuser,rvexcludeuser

See also