Basic information you should know about API

Pavara Manupriya
5 min readMay 14, 2020

If you are a person who interested in programming or any kind of IT-related development, you almost already know the term “API”. Whether you are a beginner or not, reading this article will give you a broad and accurate insight into API.

What is API?

Technically, API stands for Application Programming Interface. I would like to describe the term by using simple examples rather than using advanced technical words. The best way to start learning about any acronym is to focus on each letter. Let’s consider the last letter of API. It stands for Interfaces.

Just think about a radio interface. It allows me to change the volume, change the station, and power on-off. But the user has no idea how anything inside this thing works. The radio interface abstracts some things from the users and allows them to control the way it works.

A graphical user interface is a form of user interface that allows users to interact with electronic devices through graphical icons.

People use some kind of application when they are listening to music via mobile phones. They have a clear idea of what happens when they press the play button but they don’t know the procedure of how it happens. The developer of this application understands how the play button works. The developer coded the play button so that it gets clicked the music starts playing. Here, the developer negotiates with some interfaces that are abstracting away some of the information from him. The button is a part of the API available on the application framework that was used to create the app.

According to the above examples, you can easily understand the meaning of the term “Interface”. Graphical User Interfaces(GUI) are made for the users of the application and the Application Programming Interfaces(API) are made for the software developer of that particular application.

API consists set of rules that describe the interaction between two applications and the mechanism of that interaction occurs.

The interaction occurs when one application uses the data of another application or send the data to that particular application. Another interaction happens when one application requests a service of another application.

API types

There are several main types of API.

  1. Web service APIs
  2. Web sockets APIs
  3. Library based APIs
  4. Class-based APIs (Object orientation)
  5. OS functions and routines
  6. Object remoting APIs
  7. Hardware APIs

Web Service API

A web service API is a software or system that exchanges information among clients via HTTP protocol.

Client-Server Architechture

When the client(application) wants to communicate with the server it sent a request. The client uses the HTTP protocol to connect to the server. HTTP stands for Hypertext Transfer Protocol.

So the browser creates an HTTP request with a specified HTTP method such as GET, POST, PUT, etc. Finally, the server generates a response and sends it to the client. The body of the response contains an HTML page modified with JSON and XML.

Examples:- Flickr API, Google Static Maps API, Google Maps Wen Services

Basic types of web service API:-

  • SOAP (Simple Object Access Protocol)
  • XML-RPC
  • JSON-RPC
  • REST (Representational State Transfer)

SOAP is a standardized protocol that sends messages using other protocols such as HTTP and SMTP. The data transfer format is XML.

XML-RPC is also a protocol that is older than SOAP and supports different levels of libraries. You can find the differences between SOAP and XML-RPC by inspiring this Stack Overflow thread.

JSON_RPC is similar to XML-RPC. The only difference is using JSON instead of XML for the data transmitting procedure.

REST API

Rest is not a protocol. It uses the concept that was introduced with the web to expose the resources that can be accessed and manipulated. The REST API sits on the top of web technology.

example for rest API — JIRA REST APIs from Atlassian

An API required a set of architectural constraints to be considered as RESTFUL.

  1. Client-Server Architecture — we discussed this at the beginning of this subsection.
  2. Statelessness — As per the rest, the server doesn’t store any information about the client session on the server-side. If you want to state like your origin details you must send it with each request and you can do the task using headers.
  3. Layered System — Layered System consists of layers with the different units of functionality. The layers communicate using pre-defined interfaces and communicate only with the layer above or layer below.
  4. Cacheability- Cache constraints require that the data within a response to identifying that data is cacheable or non-cacheable. If the data is cacheable, the server can reuse the response for the same type of request.
  5. Uniform Interface — There are four main interface constraints in the REST API. Identification of resources, manipulation of resources through representations, self-descriptive messages, and hypermedia are the main constraints. You can learn more about this by referring blog RESTCASE.
  6. Code on Demand — This is an optional constraint. Code-On-Demand means that a server can extend the functionality of a client on runtime, by sending code to it that it should execute (like Java Applets, or JavaScript).

Library Based APIs

We use library-based APIs usually when we are coding. They are local to our codebase and exist within our code. We used them to avoid recreating the wheel. Native library APIs are specific to a particular programming language.

Examples:- Twilio API libraries, Javascript libraries

Class-based APIs (Object orientation)

Class-based API is a special type of library-based API. Class-based API used object-oriented languages for providing data.

Examples:- Java API, Android API

OS functions and routines

This is the type of API that helps to execute the operating system.

Examples:- Access to the file system, Access to the user interface

Object Remoting API

There are two types of object remoting API named .NET remoting and cobra. Most of these APIs are now considered legacy.

Hardware API

Hardware APIs are for manipulating addressable pieces of hardware on a device. Hardware APIs have used in video acceleration, hard disk drives, and PCI buses.

summary of API types- Please follow the API TYPES document in Slideshare.

Additional Readings:-

Conclusion

That’s all the good stuff. You just completed a whirlwind introduction to APIs and I hope you see how much of power they can add your programming journey. I hope you are more comfortable with my introduction. If you have any issues, don’t forget to put a comment on the comment section. I will do my best to figure it out.

If you think this is important to another person, please share it with them. Please stay with my articles to learn more.

--

--

Pavara Manupriya

Undergraduate at UOM | IOS Developer | Full Stack Developer