API
Using the primary API, you can place a request as such:
curl https://html.haus/api/elements/abbr.json
You will receive a result that looks like this:
{
"name": "abbr",
"description": "Abbreviation element represents an acronym",
"code": "https://html.haus/api/elements/abbr.html",
"url": "https://html.haus/reference.html#abbr"
}
You can use references to code to also request the sample HTML:
curl https://html.haus/api/elements/abbr.html
A comprehensive list of all elements supported is available here:
curl https://html.haus/api/index.json
JavaScript
Ultimately, this means you can use JavaScript fetch functions to query the API using this formula:
https://html.haus/api/elements/${element-name}.json
https://html.haus/api/elements/${element-name}.html
Here's an example using the standard fetch() function:
fetch('https://html.haus/api/elements/${element-name}.json').then(function (response) {
// The API call was successful!
return response.json();
}).then(function (html) {
// This is the JSON from our response
console.log(html);
}).catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});