Wikipedia / MediaWiki Pages API

Page metadata, HTML, source, create, update

OpenAPI Specification

wikipedia-pages-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: MediaWiki Action articles Pages 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: Pages
  description: Page metadata, HTML, source, create, update
paths:
  /page/{title}:
    get:
      operationId: getPage
      summary: MediaWiki Core REST Get Page Source and Metadata
      description: Retrieve a wiki page including its wikitext source and metadata.
      tags:
      - Pages
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: title
        in: path
        required: true
        schema:
          type: string
        description: URL-encoded page title
        example: Earth
      - name: redirect
        in: query
        schema:
          type: string
          enum:
          - 'true'
          - 'false'
          - 'no'
        description: Whether to resolve redirects
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    put:
      operationId: updatePage
      summary: MediaWiki Core REST Update or Create a Page
      description: Update an existing page, or create one if it does not exist. Optimistic concurrency via latest.id.
      tags:
      - Pages
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: title
        in: path
        required: true
        schema:
          type: string
        description: URL-encoded page title
        example: Earth
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePageRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - BearerAuth: []
  /page/{title}/bare:
    get:
      operationId: getPageBare
      summary: MediaWiki Core REST Get Page Metadata Without Content
      description: Retrieve metadata about a page including a link to its rendered HTML.
      tags:
      - Pages
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: title
        in: path
        required: true
        schema:
          type: string
        description: URL-encoded page title
        example: Earth
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /page/{title}/html:
    get:
      operationId: getPageHtml
      summary: MediaWiki Core REST Get Page as HTML
      description: Retrieve the rendered HTML for a page.
      tags:
      - Pages
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: title
        in: path
        required: true
        schema:
          type: string
        description: URL-encoded page title
        example: Earth
      responses:
        '200':
          description: Rendered HTML
          content:
            text/html:
              schema:
                type: string
  /page/{title}/with_html:
    get:
      operationId: getPageWithHtml
      summary: MediaWiki Core REST Get Page Metadata and HTML
      description: Retrieve page metadata together with rendered HTML.
      tags:
      - Pages
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: title
        in: path
        required: true
        schema:
          type: string
        description: URL-encoded page title
        example: Earth
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /page:
    post:
      operationId: createPage
      summary: MediaWiki Core REST Create a New Wiki Page
      description: Create a new wiki page. Requires OAuth bearer token and a CSRF token.
      tags:
      - Pages
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePageRequest'
      responses:
        '201':
          description: Page created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page'
      security:
      - BearerAuth: []
components:
  schemas:
    UpdatePageRequest:
      type: object
      required:
      - source
      - comment
      - latest
      properties:
        source:
          type: string
        comment:
          type: string
        content_model:
          type: string
        latest:
          type: object
          required:
          - id
          properties:
            id:
              type: integer
              description: Latest revision ID known to the client (for optimistic concurrency)
        token:
          type: string
    CreatePageRequest:
      type: object
      required:
      - source
      - title
      - comment
      properties:
        source:
          type: string
          description: Wikitext source for the new page
          example: '''''''Hello, world.'''''''
        title:
          type: string
          description: New page title
          example: User:Example/Sandbox
        comment:
          type: string
          description: Edit summary
          example: Creating sandbox page
        content_model:
          type: string
          example: wikitext
        token:
          type: string
          description: CSRF token from Action API
    Page:
      type: object
      description: A MediaWiki page object.
      properties:
        id:
          type: integer
          example: 9228
          description: Page ID
        key:
          type: string
          example: Earth
          description: Page DB key (URL form)
        title:
          type: string
          example: Earth
          description: Display title
        latest:
          type: object
          properties:
            id:
              type: integer
              example: 1356767710
              description: Revision ID
            timestamp:
              type: string
              format: date-time
              example: '2026-05-29T18:21:47Z'
        content_model:
          type: string
          example: wikitext
        license:
          type: object
          properties:
            url:
              type: string
              format: uri
              example: https://creativecommons.org/licenses/by-sa/4.0/
            title:
              type: string
              example: Creative Commons Attribution-Share Alike 4.0
        html_url:
          type: string
          format: uri
        source:
          type: string
          description: Page wikitext source
        html:
          type: string
          description: Rendered HTML
    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
  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