openapi: 3.0.0
info:
  title: Wikipedia Article API
  description: |
    Get one Wikipedia page by its title, page id, Wikipedia URL or Wikidata id, in any of 348 editions.

    The article carries the page id, the id of the latest revision and the time of the last edit, the Wikidata id, the short description, the lead section as plain text, the lead image, the visible categories and the links to the same subject in other editions. Set `text_format` to add the whole page as plain text, HTML (with its sections) or wikitext.

    Pass exactly one of `title`, `page_id`, `url` and `wikidata_id`. A title Wikipedia redirects is answered with the page it redirects to, and `redirect_title` names the title given. `is_featured_article` and `is_good_article` mark the pages the edition rates as its featured and good articles. A page Wikipedia doesn't have, a title it doesn't accept, a special page, an interwiki title pointing to another wiki, and a Wikidata item that is unknown or has no page in the edition return `error` instead of `article`.

    **Cross-linking**: the `page_id` of each result from the Wikipedia Search API opens here with the same `language`, and `language_links[].language` with `language_links[].title` opens the same subject in another edition when `language` supports that edition. A link can also point to a closed, read-only edition, which `language` does not take.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Wikipedia Article
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `wikipedia_article`'
          schema:
            type: string
            enum: ["wikipedia_article"]
        - name: title
          in: query
          required: false
          description: Title of the page, as Wikipedia shows it, up to 255 bytes. Underscores count as spaces. Exactly one of `title`, `page_id`, `url` or `wikidata_id` is required.
          schema:
            type: string
        - name: page_id
          in: query
          required: false
          description: Wikipedia page id, unique within an edition, such as a `page_id` from the Wikipedia Search API.
          schema:
            type: integer
            minimum: 1
            maximum: 4294967295
        - name: url
          in: query
          required: false
          description: Link to a Wikipedia page, on an edition's desktop or mobile address, as `/wiki/<title>` or `/w/index.php` with `curid` or `title`. Chinese and Serbian variant paths such as `/zh-tw/` and `/sr-el/` also work. The address sets the edition. Links containing `oldid` return the latest revision. The reported URL preserves the variant, while content uses the script returned by the Wikipedia API.
          schema:
            type: string
            maxLength: 2048
        - name: wikidata_id
          in: query
          required: false
          description: Wikidata item id, such as `Q937`. Returns the item's page in the edition `language` sets.
          schema:
            type: string
            pattern: '^[Qq][1-9]\d{0,11}$'
        - name: language
          in: query
          required: false
          description: Wikipedia edition, by the code in its address, such as `en`, `de` or `zh-yue`.
          schema:
            type: string
            enum: ["ab", "ace", "ady", "af", "als", "alt", "am", "ami", "an", "ang", "ann", "anp", "ar", "arc", "ary", "arz", "as", "ast", "atj", "av", "avk", "awa", "ay", "az", "azb", "ba", "ban", "bar", "bat-smg", "bbc", "bcl", "bdr", "be", "be-tarask", "bew", "bg", "bh", "bi", "bjn", "blk", "bm", "bn", "bo", "bol", "bpy", "br", "bs", "btm", "bug", "bxr", "ca", "cbk-zam", "cdo", "ce", "ceb", "ch", "chr", "chy", "ckb", "co", "crh", "cs", "csb", "cu", "cv", "cy", "da", "dag", "de", "dga", "din", "diq", "dsb", "dtp", "dty", "dv", "dz", "ee", "el", "eml", "en", "eo", "es", "et", "eu", "ext", "fa", "fat", "ff", "fi", "fiu-vro", "fj", "fo", "fon", "fr", "frp", "frr", "fur", "fy", "ga", "gag", "gan", "gcr", "gd", "gl", "glk", "gn", "gom", "gor", "got", "gpe", "gu", "guc", "gur", "guw", "gv", "ha", "hak", "haw", "he", "hi", "hif", "hr", "hsb", "ht", "hu", "hy", "hyw", "ia", "iba", "id", "ie", "ig", "igl", "ik", "ilo", "inh", "io", "is", "isv", "it", "iu", "ja", "jam", "jbo", "jv", "ka", "kaa", "kab", "kai", "kaj", "kbd", "kbp", "kcg", "kg", "kge", "ki", "kk", "km", "kn", "knc", "ko", "koi", "krc", "ks", "ksh", "ku", "kus", "kv", "kw", "ky", "la", "lad", "lb", "lbe", "lez", "lfn", "lg", "li", "lij", "lld", "lmo", "ln", "lo", "lt", "ltg", "lv", "mad", "mag", "mai", "map-bms", "mdf", "mg", "mhr", "mi", "min", "mk", "ml", "mn", "mni", "mnw", "mos", "mr", "mrj", "ms", "mt", "mwl", "my", "myv", "mzn", "nah", "nap", "nds", "nds-nl", "ne", "new", "nia", "nl", "nn", "no", "nov", "nqo", "nr", "nrm", "nso", "nup", "nv", "ny", "oc", "olo", "om", "or", "os", "pa", "pag", "pam", "pap", "pcd", "pcm", "pdc", "pfl", "pi", "pl", "pms", "pnb", "pnt", "ppl", "ps", "pt", "pwn", "qu", "rki", "rm", "rmy", "rn", "ro", "roa-rup", "roa-tara", "rsk", "ru", "rue", "rw", "sa", "sah", "sat", "sc", "scn", "sco", "sd", "se", "sg", "sh", "shi", "shn", "si", "simple", "sk", "skr", "sl", "sm", "smn", "sn", "so", "sq", "sr", "srn", "ss", "st", "stq", "su", "sv", "sw", "syl", "szl", "szy", "ta", "tay", "tcy", "tdd", "te", "tet", "tg", "th", "ti", "tig", "tk", "tl", "tly", "tn", "to", "tok", "tpi", "tr", "trv", "ts", "tt", "tum", "tw", "ty", "tyv", "udm", "ug", "uk", "ur", "uz", "ve", "vec", "vep", "vi", "vls", "vo", "wa", "war", "wo", "wuu", "xal", "xh", "xmf", "yi", "yo", "za", "zea", "zgh", "zh", "zh-classical", "zh-min-nan", "zh-yue", "zu"]
            default: "en"
        - name: text_format
          in: query
          required: false
          description: Adds the whole page as plain text in `text`, as HTML in `html` with its `sections`, or as wikitext in `wikitext`. The plain-text format omits tables. Without `text_format`, the article carries the lead section only.
          schema:
            type: string
            enum: ["plain", "html", "wikitext"]
        - name: zero_retention
          in: query
          required: false
          description: Set to true to disable logging and persistent storage for this request. Enterprise plans only.
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden. Zero data retention is not available to the account, or the account requires `zero_retention=true`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Timeout. We could not retrieve results in 90 seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        article:
          $ref: '#/components/schemas/Article'
        error:
          type: string
          description: Why the lookup returned no page.
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: "Unique identifier for the search request"
        status:
          type: string
          description: "Status of the search request"
        created_at:
          type: string
          format: date-time
          description: "Timestamp when the search was created"
        request_time_taken:
          type: number
          description: "Time taken to make the request in seconds"
        parsing_time_taken:
          type: number
          description: "Time taken to parse the results in seconds"
        total_time_taken:
          type: number
          description: "Total time taken for the search in seconds"
        request_url:
          type: string
          description: "Wikipedia page for this lookup"
        html_url:
          type: string
          description: "URL to view the raw results"
        json_url:
          type: string
          description: "URL to view JSON results"
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used
        title:
          type: string
          description: Title of the page asked for
        page_id:
          type: integer
          description: Page id asked for
        url:
          type: string
          description: Link to the page asked for
        wikidata_id:
          type: string
          description: Wikidata item id asked for
        language:
          type: string
          description: Wikipedia edition the page was looked up in
        text_format:
          type: string
          description: Format of the whole page's text
        zero_retention:
          type: boolean
          description: Whether zero data retention was requested
    Article:
      type: object
      required: [page_id, title, link, language, text_direction, namespace, revision_id, updated_at, size_bytes]
      properties:
        page_id:
          type: integer
          description: Wikipedia page id, unique within the edition.
        title:
          type: string
          description: Page title.
        link:
          type: string
          description: Link to the page.
        language:
          type: string
          description: Code of the page's edition, as the language parameter takes it.
        text_direction:
          type: string
          enum: ["ltr", "rtl"]
          description: Direction of the edition's script, left to right or right to left.
        namespace:
          type: integer
          description: Id of the page's namespace, 0 for articles.
        wikidata_id:
          type: string
          description: Wikidata item id of the page's subject.
        description:
          type: string
          description: Short description of the page's subject.
        revision_id:
          type: integer
          description: Id of the page's latest revision.
        updated_at:
          type: string
          format: date-time
          description: Time of the page's last edit, in UTC.
        size_bytes:
          type: integer
          description: Size of the page's source text in bytes.
        is_disambiguation:
          type: boolean
          description: Whether the page is a disambiguation page.
        is_featured_article:
          type: boolean
          description: Whether the edition rates the page a featured article, its highest grade.
        is_good_article:
          type: boolean
          description: Whether the edition rates the page a good article.
        redirect_title:
          type: string
          description: Title Wikipedia redirected to this page.
        summary:
          type: string
          description: Lead section of the page as plain text.
        thumbnail:
          type: string
          description: Thumbnail of the page's lead image.
        image:
          $ref: '#/components/schemas/Image'
        categories:
          type: array
          description: Categories the page shows to readers.
          items:
            $ref: '#/components/schemas/Category'
        language_links:
          type: array
          description: Pages on the same subject in other editions.
          items:
            $ref: '#/components/schemas/LanguageLink'
        text:
          type: string
          description: Page as plain text with section headings such as `== History ==`. Tables are omitted.
        html:
          type: string
          description: HTML of the page's content.
        sections:
          type: array
          description: Sections of the page, in the order of its HTML.
          items:
            $ref: '#/components/schemas/Section'
        wikitext:
          type: string
          description: Wikitext source of the page's latest revision.
    Image:
      type: object
      required: [link, width, height]
      properties:
        link:
          type: string
          description: Link to the lead image file in its original size.
        width:
          type: integer
          description: Width of the original image in pixels.
        height:
          type: integer
          description: Height of the original image in pixels.
    Category:
      type: object
      required: [title, link]
      properties:
        title:
          type: string
          description: Category name, without the namespace prefix.
        link:
          type: string
          description: Link to the category page.
    LanguageLink:
      type: object
      required: [language, title, link]
      properties:
        language:
          type: string
          description: Code of the other edition, by the code in its address.
        title:
          type: string
          description: Title of the page in the other edition.
        link:
          type: string
          description: Link to the page in the other edition.
    Section:
      type: object
      required: [level, number, title, anchor, link]
      properties:
        level:
          type: integer
          minimum: 1
          maximum: 6
          description: Heading level of the section, including level 1 headings on pages such as the English Main Page.
        number:
          type: string
          description: Number of the section in the table of contents, such as `2.1`.
        title:
          type: string
          description: Section heading as plain text.
        anchor:
          type: string
          description: Anchor of the section heading in the page's HTML.
        link:
          type: string
          description: Link to the section.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
