Chapter 13. Fun with APIs

An API is a defined interface that acts like a handshake between software components, allowing one component to access another even though the components have been developed separately.

APIs vary widely: from those built into operating systems allowing developers to access OS-specific functionality, to functional APIs that are grouped to allow access to specific types of functionality (in the browser or accessible in the server). APIs are also used to provide a bridge between a client on one machine, to a service or resource on another.

An API isn’t a library or module, though both can implement APIs. They’re more a contract between developers where the API implementer promises to provide certain functionality, as long as people accessing the functionality play nice (and don’t abuse the privilege, in the case of remote services).

In this chapter, we look at APIs in all their glorious forms: how to access, how to create, and how to use.

Note

A really great resource listing many of the web APIs, or APIs that can be used to allow web applications to access hardware and locally stored data, is the WebAPI page offered in the Mozilla Developer Network (MDN). The MDN provides a single page resource page detailing all specifications, in development or stable.

Accessing JSON-Formatted Data via a RESTful API

Problem

You want to access data formatted as JSON from a service through their API. You need to access the data both in a client and in a Node application, but don’t ...

Get JavaScript Cookbook, 2nd Edition 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.