Chapter 17

HTML5 APIs

In This Chapter

arrow Discovering APIs

arrow Taking advantage of geolocation

arrow Accessing media

Language is a virus from outer space.

— William S. Burroughs

HTML5’s APIs provide you with access to a wide range of computer and mobile device functionality. In this chapter, you discover how to use APIs, the standard methods and techniques used by APIs, and example code for working with some of the more exciting APIs.

Understanding How APIs Work

APIs, or Application Programming Interfaces, are sets of software routines and standards that give programmers access to the capabilities of a software application. APIs are the means by which one computer program gives another computer program the ability to interact with it. When a web browser allows a JavaScript program to interact with it, it does so by using APIs.

For example, the W3C’s Battery Status APIs describes how browsers should report data about what’s currently happening with the battery in a device (such as a smartphone or tablet). Other programs (for example, JavaScript programs within web pages) can access the Battery Status API to find out whether the device’s battery is low, or charging, or how much battery ...

Get Coding with JavaScript For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.