Published on

What are APIs and REST APIs? - A Simple Explanation


In this post, we will try to demystify the word API and REST APIs in very simple terms so that it can hopefully help whoever is struggling to understand those concepts.

What is an API?

In very simple terms, an “Application programming interface” refers to any software that allows 2 code entities to talk to each other and to, most importantly, exchange data.


A brief history of the term "API"

The term "application program interface" was first cited in the research paper Data structures and techniques for remote computer graphics presented at an AFIPS conference in 1968. The authors of the paper used this term to describe the interaction of a software, in this case a graphics program, with the rest of the system.

How do web applications communicate ?

Just like humans need a language to communicate with each other, web applications need some rules to send and receive data back and forth. The equivalent of the human language for web applications is the HTTP protocol. Web applications communicate by sending HTTP requests back and forth.

Why do we use APIs?

The core purpose of an API is in making some data available to use for any third-party software in a very easy way.

Free public APIs

There are many free-to-use public APIs. This great github repository lists many popular free-to-use public APIs for anyone interested in trying them.

API constraints

On top of the HTTP protocol, web applications use additional rules for sending and consuming the data sent in a network. Those rules include the type of data sent and the way this data will be sent in addition to other rules. One of the popular rules set up for this purpose are the rules that makes RESTful APIs.

What does REST mean ?

REST is in simple terms, a set of rules that developers use when designing web applications that are communicating over a network. One of these rules states that you should be able to get a piece of data (called a resource) when you link to a specific URL. If a system violates any rule of the REST standard, it cannot be considered as RESTful. One of the most popular data formats used with REST APIs is the JSON format.

A Little History of REST

REST was first defined in the PHD dissertation of the computer scientist Roy Fielding named “Architectural Styles and the Design of Network-based Software Architectures” at the University of California in Irvine.

REST Rules

In order for an API to be considered as RESTful, it has to follow the six following rules :

  1. Client server architecture: There must be a clear separation between the backend and the frontend of the application in a client-server architecture
  2. Stateless: No client information is stored between requests and each request should be separate
  3. Uniform interface: The REST API should provide a uniform interface for any client that may want to consume its data.
  4. Layered system: There can be some intermediate backend programs between the client and the server making hierarchical layers in a way that each layer only sees the layer it is interacting with.
  5. Code on demand: The server can send code that can be executed on the client-side, which extends the client functionality.
  6. Cacheability: Every response should be declared as cacheable whenever possible, avoiding unnecessary processing and significantly increasing performance

Final words

In simple terms, an API is just a piece of code that allows two programs to communicate with each other. Those communications are based on a set of rules that developers follow in order to make the consumption of the data as easy and as smooth as possible.