Course sections

Understanding and Using APIs, Lecture 1

Lesson 1: Construct a REST API request to accomplish a task given API documentation

Construct a REST API request to accomplish a task given API documentation

Application Programming Interface (or an API) is an interface mechanism and a protocol to carry out communication between a server and a client with the primary purpose of simplifying the software development of client-side software.

APIs are broadly split into internal and external based on how they are used and shared in a system. Internal and external APIs are also known as private and public. Private APIs are exclusively meant to be used for building applications that are to be used within a company.

Public APIs, on the other hand, are for open use by all third parties who may be interested in building applications that use company’s services. Outside organizations are expected to use these APIs to build or extend beyond the original intent.

All major operations systems such as macOS, windows, iOS, Android have both private and public APIs. The use of private APIs by anyone outside the organization is frowned upon, and for mobile development, it simply means that your app will be rejected by iOS or Android approval teams. However, there was one famous example, where late Steve Jobs personally intervened and approved an app then known as “Knocking Live Video”.

Let’s now use cURL to issue a REST API request, cURL is a “client for URLs”, or a command line utility to transfer data using various protocols. Here we will use cURL to perform a GET operation (using the -I option tells it to only pull the HTTP headers or HEAD method). The response you see below is what is sent by the web server in response.