Extract Forms & Sections API

forms lists each form with its action, method and fields. Hidden fields don't include their value.

sections lists the page's landmark elements, such as <main>, <nav> and <footer>, with their heading, word count and a text preview. If the page has none, its largest content block is returned as main.

API Examples

Forms


JSON Example

{
  ...
  "forms": [
    {
      "position": 1,
      "action": "https://en.wikipedia.org/w/index.php",
      "method": "get",
      "id": "searchform",
      "fields": [
        {
          "name": "search",
          "type": "search"
        },
        {
          "name": "title",
          "type": "hidden"
        }
      ]
    },
  ]
}

Sections


JSON Example

{
  ...
  "sections": [
    {
      "position": 1,
      "tag": "header",
      "word_count": 38,
      "text": "Main menu Main menu move to sidebar hide Navigation Main..."
    },
    {
      "position": 2,
      "tag": "nav",
      "id": "mw-panel-toc",
      "heading": "Contents",
      "word_count": 167,
      "text": "Contents move to sidebar hide (Top) 1 Etymology 2 History..."
    },
    {
      "position": 3,
      "tag": "main",
      "id": "content",
      "heading": "Coffee",
      "word_count": 16389,
      "text": "Toggle the table of contents Coffee 209 languages..."
    },
  ]
}