Member-only story
4 Awesome Browser APIs You Might Not Be Using Yet
Keep them handy. They can be super useful!
Browser APIs are very important features of HTML incorporated inside your web browser. These Web APIs are much more powerful than you might think. There are some great APIs that are so underrated!
It’s a topic every experienced web developer should have a good mastery of, and knowing them will bring many advantages.
While there are some very well-known APIs such as the Web Storage API or the Fetch API, there are some that are very underrated and mentioned less in common tutorials!
Let’s take a look at them now!
1. The Battery API
The Battery Status API, sometimes known as the Battery API, offers information on the computer’s battery. It displays the battery’s remaining capacity and charging status. It also estimates how much longer it will take to fully charge or discharge the battery, depending on whether it is charging or discharging.
The Battery Status API is not a third-party application. It can be found in the navigator
. The navigator object’s built-in window.navigator
property has a getBattery()
method.
This API quickly queries the status of the user's battery and uses it to implement battery-saving functionalities when the user’s battery is low, like killing some background processes that drain the battery faster.
For example:
navigator.getBattery().then((battery) => {
console.log(battery);
});
And here’s the example response for the above code.
{
charging: false,
chargingTime: Infinity,
dischargingTime: 35040,
level: 0.53,
onchargingchange: null,
onchargingtimechange: null,
ondischargingtimechange: null,
onlevelchange: null
}
2. The IndexedDB API
The Web Storage API was deprecated in the HTML5 specification, and the IndexedDB API replaces it. (However, Web Storage is still supported by a number of popular browsers, including Apple’s Safari and Opera.) Indexing, transactions, and sophisticated querying capabilities are just a few of the benefits of IndexedDB over Web Storage.