Wikipedia / MediaWiki Revisions API

Individual revision retrieval and comparison

OpenAPI Specification

wikipedia-revisions-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: MediaWiki Action articles Revisions API
  description: 'The MediaWiki Action API is the original programmatic interface to MediaWiki, exposed under /w/api.php on every MediaWiki installation. All operations dispatch via the ?action= query parameter. The API supports JSON, XML, and PHP serialization; JSON is the recommended format.


    Wikimedia projects strongly recommend serial (not parallel) calls, the use of maxlag for non-interactive jobs, and a contactable User-Agent header. The Action API remains the primary write interface (edit, upload, login, patrol) even where the Core REST API is also available.'
  version: '1.45'
  x-generated-from: documentation
  x-source-url: https://www.mediawiki.org/wiki/API:Main_page
  x-last-validated: '2026-05-29'
  contact:
    name: Wikimedia Foundation
    url: https://www.mediawiki.org/wiki/API:Etiquette
  license:
    name: CC BY-SA 4.0
    url: https://creativecommons.org/licenses/by-sa/4.0/
servers:
- url: https://en.wikipedia.org/w
  description: English Wikipedia
- url: https://{lang}.wikipedia.org/w
  description: Per-language Wikipedia
  variables:
    lang:
      default: en
      description: Language code
- url: https://commons.wikimedia.org/w
  description: Wikimedia Commons
- url: https://www.wikidata.org/w
  description: Wikidata
- url: https://www.mediawiki.org/w
  description: MediaWiki.org
tags:
- name: Revisions
  description: Individual revision retrieval and comparison
paths:
  /revision/{id}:
    get:
      operationId: getRevision
      summary: MediaWiki Core REST Get Revision with HTML Link
      description: Retrieve a revision and a link to its rendered HTML.
      tags:
      - Revisions
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: Revision identifier
        example: 1356767710
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Revision'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /revision/{id}/bare:
    get:
      operationId: getRevisionBare
      summary: MediaWiki Core REST Get Revision Metadata
      description: Retrieve revision metadata without source or HTML.
      tags:
      - Revisions
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: Revision identifier
        example: 1356767710
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Revision'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /revision/{id}/source:
    get:
      operationId: getRevisionSource
      summary: MediaWiki Core REST Get Revision Wikitext Source
      description: Retrieve the wikitext source for a specific revision.
      tags:
      - Revisions
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: Revision identifier
        example: 1356767710
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Revision'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /revision/{id}/html:
    get:
      operationId: getRevisionHtml
      summary: MediaWiki Core REST Get Revision as HTML
      description: Retrieve the rendered HTML for a specific revision.
      tags:
      - Revisions
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: Revision identifier
        example: 1356767710
      responses:
        '200':
          description: HTML for the revision
          content:
            text/html:
              schema:
                type: string
  /revision/{id}/with_html:
    get:
      operationId: getRevisionWithHtml
      summary: MediaWiki Core REST Get Revision Metadata and HTML
      description: Retrieve revision metadata together with rendered HTML.
      tags:
      - Revisions
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: Revision identifier
        example: 1356767710
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Revision'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /revision/{from}/compare/{to}:
    post:
      operationId: compareRevisions
      summary: MediaWiki Core REST Compare Two Revisions
      description: Produce a structured diff between two revisions of the same page.
      tags:
      - Revisions
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: from
        in: path
        required: true
        schema:
          type: integer
        description: From revision ID
      - name: to
        in: path
        required: true
        schema:
          type: integer
        description: To revision ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompareResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CompareResponse:
      type: object
      description: Comparison between two revisions.
      properties:
        from:
          $ref: '#/components/schemas/Revision'
        to:
          $ref: '#/components/schemas/Revision'
        diff:
          type: array
          items:
            type: object
            properties:
              type:
                type: integer
                description: 0 context, 1 add line, 2 delete line, 3 in-line change, 4 moved paragraph, 5 paragraph moved into place
              lineNumber:
                type: integer
              text:
                type: string
              offset:
                type: object
                properties:
                  from:
                    type: integer
                  to:
                    type: integer
              highlightRanges:
                type: array
                items:
                  type: object
    Error:
      type: object
      properties:
        errorKey:
          type: string
          example: rest-no-match
        messageTranslations:
          type: object
          additionalProperties:
            type: string
        httpCode:
          type: integer
          example: 404
        httpReason:
          type: string
          example: Not Found
    Revision:
      type: object
      description: A page revision.
      properties:
        id:
          type: integer
          example: 1356767710
        page:
          type: object
          properties:
            id:
              type: integer
            title:
              type: string
        size:
          type: integer
          description: Byte size of revision
        minor:
          type: boolean
        timestamp:
          type: string
          format: date-time
        content_model:
          type: string
          example: wikitext
        license:
          type: object
          properties:
            url:
              type: string
              format: uri
            title:
              type: string
        user:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
              example: Jimbo Wales
        comment:
          type: string
          description: Edit summary
        delta:
          type: integer
          description: Byte delta from previous revision
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: OAuth 2.0 bearer token from meta.wikimedia.org
    CookieAuth:
      type: apiKey
      in: cookie
      name: '{wiki}wikiUserID'
      description: Session cookie obtained via action=login or action=clientlogin