Web Accessibility API – Validate HTML Accessibility via REST API
What is the Web Accessibility API?
The Aspose.HTML Cloud Web Accessibility API enables you to validate the accessibility of HTML documents according to WCAG standards. This API helps ensure your web content is accessible to all users, including those with disabilities, by checking compliance with various WCAG levels (A, AA, AAA).
- REST API only: This API is not included in SDKs and is available exclusively via direct HTTP requests.
- Single endpoint: All accessibility validation is performed via a single endpoint:
POST https://api.aspose.cloud/v4.0/html/accessibility
. - Flexible input: You can validate HTML from a URL, raw HTML content, base64-encoded content, or files stored in Aspose Cloud Storage.
How It Works
To validate accessibility, send a POST request to the endpoint with an AccessibilityRequest
object. The request can specify the HTML source (URL, content, base64, or storage path) and various validation options. The API returns a detailed report indicating whether the document passes accessibility checks and provides information about any issues found.
Request Object
The request body should be a JSON object with the following properties:
InputPath
: URL or storage path to the HTML fileInputBase64
: base64-encoded HTML contentInputContent
: raw HTML contentStorageName
: (optional) storage name if using Aspose Cloud StorageOptions
: accessibility validation options (see below)
AccessibilityOptions
The Options
object allows you to control which accessibility rules and features are checked. The available properties are:
AllLevels
,LowestLevel
,MiddleLevel
,HighestLevel
: which WCAG levels to checkWcagVersion
: WCAG version (e.g., “2.1”)UseHtml
,UseCss
,UseScript
,UseFailures
,UseGeneral
,UseAria
: enable/disable specific validation typesHtmlTags
,ExcludeTags
: comma-separated lists of tags to include/excludeMaxErrorsPerRule
: limit errors per rule
Detailed option descriptions:
AllLevels
(bool?): Check all WCAG levels (A, AA, AAA).LowestLevel
(bool?): Check only WCAG level A (lowest level).MiddleLevel
(bool?): Check only WCAG level AA (middle level).HighestLevel
(bool?): Check only WCAG level AAA (highest level).WcagVersion
(string): WCAG version to use for validation (e.g., “2.1”).UseHtml
(bool?): Enable HTML validation.UseCss
(bool?): Enable CSS validation.UseScript
(bool?): Enable JavaScript validation.UseFailures
(bool?): Enable failure validation (checks for known failures).UseGeneral
(bool?): Enable general validation (broad accessibility checks).UseAria
(bool?): Enable ARIA validation (checks for ARIA attributes and roles).HtmlTags
(string): Comma-separated list of HTML tags to validate (e.g., “img,button,input”).ExcludeTags
(string): Comma-separated list of HTML tags to exclude from validation.MaxErrorsPerRule
(int?): Maximum number of errors to report per rule.
You can combine these options to customize the accessibility validation according to your needs. For example, you can check only certain WCAG levels, focus on specific tags, or enable/disable certain types of validation.
Response Object
The response contains:
Success
: overall pass/failRules
: list of validation rules and their resultsError
: error message if validation failed
See the API Reference for full details.
Common Functionality
- Authentication: Use your Aspose Cloud credentials to authenticate requests. See Authentication Guide for details.
- Uploading Local Files: To validate a local file, upload it to Aspose Cloud Storage first. See Uploading Files for instructions.
The Web Accessibility API is available only via REST API and is not included in SDKs.