Wikipedia / MediaWiki Search API

Title and full-text search

OpenAPI Specification

wikipedia-search-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: MediaWiki Action articles Search 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: Search
  description: Title and full-text search
paths:
  /search/page:
    get:
      operationId: searchPages
      summary: MediaWiki Core REST Search Page Titles and Contents
      description: Full-text search of wiki page titles and contents.
      tags:
      - Search
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: q
        in: query
        required: true
        schema:
          type: string
        description: Search query
        example: climate change
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
        description: Result count limit
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /search/title:
    get:
      operationId: searchTitles
      summary: MediaWiki Core REST Search Page Titles
      description: Auto-complete search of wiki page titles (prefix match).
      tags:
      - Search
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
      parameters:
      - name: q
        in: query
        required: true
        schema:
          type: string
        description: Title prefix
        example: Earth
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    SearchResponse:
      type: object
      properties:
        pages:
          type: array
          items:
            $ref: '#/components/schemas/SearchResult'
    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
    SearchResult:
      type: object
      description: A search result page entry.
      properties:
        id:
          type: integer
        key:
          type: string
        title:
          type: string
        excerpt:
          type: string
          description: HTML snippet with <span class="searchmatch"> highlights
        matched_title:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        thumbnail:
          type: object
          nullable: true
          properties:
            url:
              type: string
              format: uri
            width:
              type: integer
            height:
              type: integer
            mimetype:
              type: string
              example: image/jpeg
  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