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