A Web API is a developer’s ideal tool:
API stands for Application Programming Interface.
A Web API is an interface for web applications.
A Browser API enhances the functionality of a web browser.
A Server API expands the capabilities of a web server.
All browsers come with a collection of built-in Web APIs to facilitate complex tasks and access data.
For instance, the Geolocation API can provide the coordinates of the browser’s current location.
Retrieve the latitude and longitude of the user’s location.
const myElement = document.getElementById(“demo”); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { myElement.innerHTML = “Geolocation is not supported by this browser.”; } } function showPosition(position) { myElement.innerHTML = “Latitude: “ + position.coords.latitude + “<br>Longitude: “ + position.coords.longitude; } |
Third-party APIs are not integrated into your browser.
To use these APIs, you must download the code from the web.
Examples include: