API stands for Application Programming Interface. In the context of the web, Web APIs extend the core JavaScript language by providing complex functionality that would be impossible to write from scratch, such as detecting your location or fetching data from a server across the world.
Think of an API as a "menu" of services. You don't need to know how the kitchen cooks the food; you just need to know how to order it from the menu. Web APIs allow your code to interact with the browser and the system it's running on using simple commands.
Instead of writing thousands of lines of code to communicate with a GPS satellite, you just call navigator.geolocation.getCurrentPosition(). The browser does the hard work, and the API gives you the result.
Web APIs are generally divided into two main groups:
These are built INTO your web browser. You don't need to install anything. They expose data from the browser and surrounding computer environment.
These are NOT built-in. You must get the code from somewhere else on the web (usually via a script tag or npm).
Modern browsers come packed with dozens of APIs. Here are some you will encounter frequently:
Validate and handle form data.
Manipulate session history.
Send and receive network data.
Local and session storage.
Get physical coordinates.
Run JS in the background.