API 101: Introduction to APIs (2)

— Juliet Edjere

This module will take you through learning how your devices are synced to make automation easy. It highlights some fundamental concepts around APIs, what an API is and how it is used.

APIs are everywhere and used for various purposes. When we’re talking about APIs, we’re typically referring to web APIs. With API integrations, companies can improve collaboration, productivity and performance.

To set the course, we'll take a step back and review how the internet works.

First, let's understand the concept of client-server Interaction. Simply put, in a typical client-server interaction, the client sends a request to the server and the server returns a response.

Let's take a simple example - You want to book a flight from Japan to Spain.

Typically, you initiate a search on https://www.google.com/travel/flights in clear language that the website understands. When you hit the search button, the browser (client) will send your request to a server. The server, which has some data already stored in its database, will take your input and search the existing database for departing flights. In a few milliseconds, the server will send a reply with the desired result.

A database is an organized collection of structured information or data stored electronically in a computer system.

This is made possible because of an underlying protocol, Hypertext Transfer Protocol (HTTP). This application layer protocol communicates with web browsers and web servers.

Communication in HTTP revolves around the Request-Response Cycle. The client sends the server a request to do something. The server, in turn, sends the client a response saying whether or not the server could do what the client asked.

HTTP messages are how data is exchanged between a server and a client. Each HTTP message follows a strict format according to a specification. HTTP request message contains request line, header fields and optional message data. When you type an address like http://example.com into a web browser, the "HTTP" tells the browser to use the rules of HTTP when talking with the server.

Request-Line begins with a method token followed by Request-URI and the protocol version. The URL (http://…), method (GET, POST, PUT, DELETE), headers (User-Agent…), and body (data) make up a complete HTTP request.

Let's take a practice break to view the HTTP header for facebook.com in Google Chrome.

  • Right-click on the Facebook webpage and select Inspect.
  • Click on the Network tab. Pick any HTTP request from the left panel and click on headers to view the HTTP header.
  • You will be able to see various details such as URL address, the request method, status code and a lot of other information.

The browser (client) transforms the request sent by the client into an HTTP message that the server would recognise. The browser can then understand the response from the server contained in a page. This is displayed in a HyperText Markup Language (HTML) format, which is the language for describing the meaning and structure of web pages.

Now let's get into how software programs talk to each other.

This is where an Application Programming Interface, or API, comes in. To automate tasks, we will understand how data is structured so that it can be easily understood by other applications.

What is an API and why is it important?

Let's kick things off with API basics. First, understanding what an API is.

What happens when you need to delegate your tedious and time-intensive task to another computer, app, or website? The interaction requires user interface components to talk to each other and exchange data via machine-readable interfaces. This is done through an API.

The same website principle applies to APIs. Almost all basic operations involve different software that communicates with each other. Most applications, like browsers, transfer data across platforms. On one side, the client, fetches data from another side, the server that provides the API, typically at the request of a user.

An Application Programming Interface, or API, is a set of defined rules that runs on the web server and allows computers or applications to communicate with one another. The API provides the requested data in a standard format for clients to understand and use.

It's easier to think of APIs as an intermediary layer (middleman) that processes data transfer between the application and the web server. When you refresh the Facebook app, it talks to a server via an API and fetches the newest info which automatically reflects on your account.

With an autonomous exchange of data and requests, users leverage software and applications to run a data-driven business. Effectively using APIs can reduce operational or technology costs by securely and quickly exchanging data and information. What might take human hours to accomplish can take a computer seconds through an API.

How does an API work?

To anchor ourselves, let's take a high-level picture of how an API is used.

Simply put, a client system propels a server system to do what a client wants by communicating via the API.

Most applications use the same infrastructure that web pages use by sending and retrieving data using the internet. However, unlike browsers, communication is not done using a browser, so it will use an internal program that can understand HTTP. Instead of using the HTML format, it uses an open standard text-based format called JavaScript Object Notation (JSON).

JSON is a lightweight data-interchange format easy to read and write. It can be used to make a data request, as well as understand the data retrieved.

Here’s how an API works:

  1. A client application initiates an API call to retrieve information—the API call is also known as a request. This request is processed from an application to the web server via the API’s Uniform Resource Identifier (URI).
  2. After receiving a valid request, the API makes a call to the external program or web server to do something.
  3. The server sends a response to the API with the requested information presented in JSON format.
  4. The API transfers the data over the same channel to the initial requesting application depending on the web service being used.

A Uniform Resource Identifier (URI) is a unique sequence of characters that identifies resources used by web technologies.

An API call is a process that takes place when you send a request to an API after setting up your API with the correct endpoints, that API retrieves the requested data from the external server and delivers it back to the client.

Behind the Scenes with API Documentation

When working with an API, you want to know what type of data is available.

APIs do not stop at sending and retrieving data. The way the data is structured by the developers needs to be known by the client and the server. If the client does not send information in a format understood, the client may not understand the request and thus return an error message.

This is where API documentation/Specification comes in. It's the first thing to turn to when you start working with an API.

An API enables services and products to leverage each other’s data and functionality through a documented interface. It is important for an API to be transparent about which data can be retrieved and how to do that so that it is easy to understand the enquiry and respond to it.

Companies open up their applications’ data and functionality to external third-party developers, business partners, and internal departments within their companies. The company publishing the API implements their side by writing instructions on how to structure requests and putting them on a server.

Different clients can use the API to display the same information on different platforms. Companies can use an API to simplify the process of managing existing or designing new tools. For example, travel aggregation APIs can dramatically reduce the time and effort involved in checking for available flights or accommodation.

We will revisit these fundamentals throughout the rest of the course.

📎 NEXT MODULE - Understanding the Mechanics of API Interactions


I'm Juliet Edjere, a no-code expert focused on design, product development, and building scalable solutions with no coding knowledge.

I document all things product stories, MVP validation, and how designs, data, and market trends connect.

Click. Build. Launch.

Visit my website → built with Carrd and designed in Figma

Powered By Swish