A couple of weeks ago, I got a great question from a reader of Head First HTML5 Programming:

What is a API? Is it like a constructor function or is it just an object or something else?

We use the term “API” frequently in Head First HTML5 Programming because the book is primarily about the JavaScript APIs you use to program web pages. So, what exactly is an API?

An API is an Application Programming Interface. If you write some software that can be used by another piece of software, the API is what specifies how to do it.

When you use the built-in JavaScript functions, you’re using an API, because you are using functions running in the browser (a program) that are designed to be used by other programs (your JavaScript program). We often call collections of functions that work together to achieve some purpose–like Geolocation–an API, as in “The Geolocation API”. Typically, there is some documentation somewhere (in this case, the HTML5 spec) that tells you *how* to use those Geolocation functions.

The APIs we cover in Head First HTML5 Programming include Geolocation, Web Workers, Web Storage, Canvas and Video. We also talk about using JSON with the Twitter REST API, which is an API that’s designed to be accessed via URLs. All these APIs are now part of JavaScript; each is just a group of functions that allows you to access particular functionality in the browser.

Thanks for a great question!

Don't miss out!!

Don't miss out on brain-friendly WickedlySmart updates early access to books and general cool stuff! Just give us your email and we'll send you something about once a week. 

You have Successfully Subscribed!