Learn more about APIs at Generate

APIs

In the context of the web, you might already have thought about APIs in the form of services made available by third parties (to find out more, take a look at our coder's guide to APIs).

Google, for example, exposes a Google Maps API that you can consume as a developer to integrate Google’s mapping, street view, navigation and more into your app. This involves importing scripts hosted on Google servers, then using objects and functions from those scripts in line with the API documentation, which it provides. APIs like this are generally what we’d refer to as “server-side APIs”.

However, what you might never have considered is that the basic JS functionality built into the browser is also composed of a set of APIs, which are constantly being updated. These “client-side APIs” provide many of the basic features taken for granted within JS, such as manipulating the DOM, embedding graphics/sound, or interfacing with the device you’re running on. 

More likely than not you’ll have read documentation for many of them online when building a site/app. These APIs are typically based on a single specification which ensures that all browser makers implement the functionality consistently, thus ensuring that your code works across any browser.

APIs in common use today

XMLHTTPRequest

XMLHTTPRequest has for some time been the JavaScript API used to send asynchronous requests to a server. This can allow you to, for example, retrieve data from the server and update a page without having to reload the full page. Its name is an anachronism since it works with JSON as well as XML. It’s likely to be superseded by the more recent Fetch API over time.

Web Sockets

Web sockets enable a two-way communication session to be opened between a browser and server. This enables the server to provide updates to the user without the browser needing to poll the server at an interval. Web sockets are in use on a number of sites today; on Stack Overflow they’re used to feed live notifications of responses to questions.

DOM functions

This may seem like a cop-out, but it’s important to think about. Even core JavaScript functions do things like manipulate the DOM. Think of the document object as an entry point. This means while they may be defined in separate specifications, there’s little fundamental difference between the new APIs we’ll look at below and core JavaScript functions that have been around for years.

Headshot of Henri HELLvetica

Henri HELLvetica – developer and performance master, will deliver a talk at Generate New York called Planet Of The APIs

Want to know more about APIs?

Henri HELLvetica is a man in the know. He is a freelance developer who has turned his interests to a potpourri of performance engineering with pinches of user experience.

His talk at Generate New York from 25-27 April 2018 - Planet Of The APIs: A Tale Of Performance & User Experience – peruses present-day and even experimental practices employed in measuring web apps, and providing performant user experiences. You can find him tweeting at @HenriHelvetica

Want to see Henri in the flesh extolling the virtues of APIs?
Get your ticket now