Lesson 84 +10 XP

What are Web APIs?

What are Web APIs?

A Web API is a set of features built into the browser that JavaScript can use.

Common browser APIs

  • DOM: access and change the page.
  • Fetch: get data from servers.
  • Storage: save data in the browser.
  • Geolocation: find the user's location.
  • Canvas: draw graphics.
  • Web Workers: run code in the background.

APIs are ready to use

You do not install them. They come with the browser, so code like this just works:

localStorage.setItem("name", "Ada");

The window object

Most browser APIs hang off window, the object that represents the browser window.

window.alert("Hi");
window.location.href;

Why APIs matter

Web APIs give you superpowers: maps, animations, data storage, notifications, and more, all without extra libraries.

TL;DR

  • Web APIs are browser-built features.
  • Examples: DOM, Fetch, Storage, Geolocation.
  • No installation needed.
  • Most are available through the window object.