HTML Web APIs
"Web API" is the umbrella term for the JavaScript interfaces browsers expose for talking to the page, the user, and the device — without third-party plugins.
Useful Web APIs
| API | Lets you… |
|---|---|
| DOM | Read and change the document tree. |
| Fetch | Make HTTP requests. |
| Geolocation | Read the user's latitude and longitude (with permission). |
| Web Storage | Save key/value data in localStorage or sessionStorage. |
| IndexedDB | Store larger, queryable data on the device. |
| Web Workers | Run JavaScript on a background thread. |
| Service Workers | Intercept network requests — enables offline and Progressive Web Apps. |
| WebSocket | Two-way real-time connection. |
| Server-Sent Events | Server-pushed updates over HTTP. |
| Canvas / WebGL / WebGPU | 2D and 3D graphics. |
| Web Audio | Generate and process sound. |
| Notifications | Show system notifications. |
| Clipboard | Read and write the clipboard (with permission). |
| Drag and Drop | Make any element draggable / droppable. |
Tip: Many APIs require a secure context (HTTPS) and explicit user permission. Always handle the "denied" case gracefully — never block the user just because they said no to a prompt.
Example
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Web APIs</title>
</head>
<body>
<h1>HTML Web APIs</h1>
<p>This is a demo page for the "HTML Web APIs" lesson.</p>
</body>
</html>
Try it Yourself »
Exercise
Name the Web API method used to make HTTP requests in modern JavaScript.
const res = await
('/api/users');
Five letters. Replaced XMLHttpRequest.
Discussion
Loading…