O'Reilly logo

JavaScript Cookbook, 2nd Edition by Shelley Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required