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
Sections
{
...
"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..."
}
]
}
JSON Structure Overview
{
...
"forms": [
{
"position": "Integer - Position of the form",
"action": "String - URL the form submits to",
"method": "String - HTTP method of the form (e.g. 'get', 'post')",
"name": "String - Name attribute of the form",
"id": "String - ID attribute of the form",
"fields": [
{
"name": "String - Name attribute of the field",
"type": "String - Type of the field (e.g. 'text', 'hidden', 'submit', 'select', 'textarea')",
"value": "String - Value of the field. Not included for hidden fields",
"placeholder": "String - Placeholder of the field",
"label": "String - Label of the field",
"fieldset": "String - Legend of the field's fieldset",
"required": "Boolean - Returns true if the field is required",
"checked": "Boolean - Returns true if the field is checked",
"disabled": "Boolean - Returns true if the field is disabled",
"readonly": "Boolean - Returns true if the field is read-only",
"options": [
{
"value": "String - Value of the option, if different from its text",
"text": "String - Text of the option",
"group": "String - Label of the option's optgroup",
"selected": "Boolean - Returns true if the option is selected"
},
...
]
},
...
]
},
...
],
"sections": [
{
"position": "Integer - Position of the section",
"tag": "String - Element of the section (e.g. 'main', 'nav', 'header', 'footer', 'section', 'article', 'aside')",
"id": "String - ID attribute of the section",
"role": "String - Role attribute of the section",
"heading": "String - First heading in the section",
"word_count": "Integer - Number of words in the section",
"text": "String - Text of the section, up to 4,000 characters"
},
...
],
...
}