Test a piece of HTML for spelling, grammar and accessibility issues
/v1/inspector/html-fragment-testUses allowanceTests a piece of HTML, such as <h1>Our wines</h1> or a whole draft page,
there and then, and answers with what each check found. Use it to check
content before you publish it. Nothing is saved, and no website is needed.
Only some checks can run on HTML alone: Silktide's own spelling, grammar, readability and accessibility checks, the ones certain enough to report an error. A fragment has no styles, scripts, headers or other files, so checks that need them, such as color contrast or broken links, are left out, and so are checks from your policies. The list depends on the account, so read it from the answer rather than assuming it.
A fragment is tested as a page on its own, so a short one fails page-level
checks such as a missing <title> or page language. Ignore the checks that
do not apply to what you sent.
Send options with website.languages. Without it, spelling and grammar
are checked in US English.
When the account has AI spell check turned on, the spelling check asks an AI model about each word no dictionary recognizes. That costs Silktide money, not the account's balance, and makes a call take several seconds; words it has seen before are answered from what it learned then.
A missing or empty html fails with status 400 and an InvalidRequest
error whose properties.field is html.
curl -X POST "https://api.eu.silktide.com/v1/inspector/html-fragment-test" \
-H "Authorization: silktide token=$SILKTIDE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<p>Our wines are <img src=\"barrel.png\"> aged in oak barels.</p>",
"options": {
"website.languages": [
"en-US"
]
}
}'{
"checks": [
{
"checkId": "missing-alt",
"name": "Missing alt text",
"standard": "WCAG 2.0 A 1.1.1",
"score": 66.67,
"numIssues": 1,
"testStatus": "tested",
"points": [
{
"pointId": "055b0fba2ac90a62cca156afc9f47d21",
"selectors": [
{
"match": "html>p>img",
"type": "css"
}
],
"firstSeen": null,
"newnessKeys": null,
"html": "<img src=\"barrel.png\">",
"isSightVisible": true,
"classification": "10-visible",
"src": "https://example.com/barrel.png",
"srcHash": "98bd9120b407057c1b84d7fdada63291",
"srcType": "image",
"mediaType": "image",
"before": "",
"after": "",
"width": null,
"height": null
}
]
},
{
"checkId": "readability",
"name": "Readability",
"standard": "",
"score": null,
"numIssues": 0,
"testStatus": "not-enough-text",
"points": []
},
{
"checkId": "spelling",
"name": "Spelling",
"standard": "",
"score": 39.44,
"numIssues": 1,
"testStatus": "tested",
"points": [
{
"pointId": "c5f2e207cbb58d9d26147ae6f7e94485",
"selectors": [
{
"match": "barels",
"caseSensitive": true,
"cssSelector": "html>p",
"type": "text"
}
],
"firstSeen": null,
"newnessKeys": null,
"word": "barels",
"suggestions": [
"barrels"
],
"correction": "",
"detectedLanguage": "en-US",
"classification": "10-error",
"before": " aged in oak ",
"after": ".",
"insideContext": "",
"languages": [
"en-US"
],
"isSightVisible": true,
"spellingSource": "ai"
}
]
}
]
}Request
Body
JSON, sent with Content-Type: application/json.
htmlstringrequiredat least 1 charactersThe HTML to test: a whole page or part of one.
urlstringThe address to treat the HTML as coming from, for resolving relative links and images. Defaults to
https://example.com/.optionsmap of any JSONWebsite settings to test with, by name, as on Update a website. Send
website.languages, such as["en-GB"]: it is the only way the spelling, grammar and readability checks know the language. Defaults to US English.
Response
200JSON.
checkslist of objectsrequiredEach check that can test a fragment of HTML, and what it found.
Show 7 fieldsHide fields
checkIdstringrequiredThe check's id, such as
spelling.namestringrequiredThe check's short name, in the API user's language.
standardstringrequiredThe standard it tests against, such as
WCAG 2.0 A 1.1.1. Can be empty.scorenumberrequiredcan be null0 to 100Its score for the HTML out of 100, to two decimal places. Null when it could not test it.
numIssuesintegerrequiredHow many issues it found.
testStatusstringrequiredtestedwhen the check ran. Anything else says why it could not, such asnot-enough-textorno-checkable-languages.pointslist of objectsrequiredEach issue it found. Empty when it found none.
Show 35 fieldsHide fields
pointIdstringrequiredThe issue's id.
selectorslist of objectsrequiredcan be nullWhere in the HTML the issue is. Null when it is about the HTML as a whole, such as a missing
<title>.Show 4 fieldsHide fields
typestringrequiredtextto highlight some text,cssto highlight the elements a CSS selector matches.One of
textcssmatchstringrequiredThe text to find, or the CSS selector.
cssSelectorstringWith
type: text, the element to look for the text in. Can be empty.caseSensitivebooleanWith
type: text, whether the text must match case.
descriptionIdstringWhich explanation of the issue applies, when its check has more than one.
firstSeennullrequiredWhen the issue was first seen. Always null here: a fragment has no history.
newnessKeysnullrequiredAlways null here.
htmlstringThe HTML of the element at fault.
htmlHashstringA hash of
html.textstringThe text at fault.
isVisiblebooleanWhether the element is visible when the page loads.
isSightVisiblebooleanWhether a sighted reader sees it, as opposed to text only for screen readers.
classificationstringHow the check grades the issue. For spelling:
10-error,15-language(a word in another language),20-potentialor30-case. For images:10-visibleor20-invisible.wordstringSpelling: the word not recognized.
suggestionslist of stringsSpelling: words it may have meant. Can be empty.
correctionstringSpelling: the word as HTML with the letters to delete in
<del>, such asha<del>z</del>. Empty when the fix needs more than deleting letters.detectedLanguagestringcan be nullSpelling: the language the word seems to be in, when it can tell.
languageslist of stringsSpelling: the languages the word was checked in.
insideContextstringSpelling: where the word is when it is not plain text, such as
alt,title,metaorscreen-reader. Empty otherwise.spellingSourcestringSpelling: what flagged the word:
hunspell(a dictionary),global(Silktide's word list),account(the account's dictionary) orai(an AI model).beforestringThe text just before the issue.
afterstringThe text just after the issue.
typostringGrammar: the text at fault.
replacementslist of stringsGrammar: what to replace
typowith.descriptionstringGrammar: what is wrong, in a sentence.
ruleDescriptionstringGrammar: the rule that found it.
grammarRuleIdstringGrammar: the rule's id.
languagestringGrammar: the language of the text.
srcstringMedia: the URL of the image, audio or video, resolved against
url.srcHashstringMedia: a hash of
src.srcTypestringMedia: the kind of source, such as
image.mediaTypestringMedia:
image,audioorvideo.widthnumbercan be nullThe element's width in CSS pixels. Null when unknown, as it usually is for a fragment.
heightnumbercan be nullThe element's height in CSS pixels. Null when unknown.
linkUrlstringLinks: the link's URL, resolved against
url.linkUrlHashstringLinks: a hash of
linkUrl.linkTextstringLinks: the link's accessible name.
Errors
| Status | Type | When |
|---|---|---|
| 400 | InvalidRequest | html is missing or empty, url is not text, or options is not an object. properties.field names which. |
| 401 | NotLoggedIn | No API key was sent, or it is not a key for this region.(any operation) |
| 429 | TooManyRequests | Too many requests to this path in five seconds. Retry after the number of seconds in the Retry-After header, which properties.retryAfter repeats.(any operation) |
| 503 | - | Silktide is busy. Retry after the number of seconds in the Retry-After header.(any operation) |
Every error has the same body. See Errors.
Access
- Permission
- Any user of the account
- Plan feature
- None
- Edition
- Silktide 4 and Silktide 5
- Cost
- Uses the account's allowance
- Available since
- v1.0.0
Try it
Sends a real request to your account from this browser. Your key stays in this tab and goes only to the Silktide API.