What is a Web API, Web Services and how does it work?

8 mins
16 Nov 2023

If you are a developer or programmer, you may already be familiar with the web API. The API is used to retrieve data and simplify the development process to make it more effective and faster. Then what is the explanation, how it works, and examples? Big companies like Google or Facebook create their own web API to help lighten the workload on their servers.

Some of these services can even be used by anyone around the world with specific needs, for example, by taking the last few posts from Instagram using this method, which we will explain later below.


What is a Web API, and how does it work?



1. What is a Web API?

API, or Application Programming Interface, is an interface that connects one application to another in any programming language. API is an intermediary in connecting the application or cross-platform.

This method can be analogous to ordering food in a restaurant. When you order food, the waiters will provide the available food menu. After you finish ordering from the menu, the waiters will forward your food order to the chef, and the chef will pass on your food after it's finished cooking. The waiters are the API, and the menu is the data that you input into this method.

The API is accessed using the HTTP protocol and is used as a tool to communicate with other developers using various programming languages, such as PHP, Java, Ruby,.NET, Node.js, etc., that aim to request certain data. Where the owner or developer does not need to provide data but can retrieve data only with this method.

A website will find it easier to develop quickly. For example, to retrieve data, a website will create its own endpoint to retrieve data, which will later be displayed on the front-end.


2. What are the types of Web APIs?

APIs are divided into 4 types with different functions: private, public, partner,  and composite.

1. Private API

Private is only used by certain users and cannot be used by the public, and its use will be limited. And it is commonly used for smaller environments, for example, a front-end will link information to be displayed through private APIs from certain platforms or application development that focuses on mobile applications that specifically retrieve data from personal services.

2. Public API

A public API is a data access right that can be used by anyone. Its use is quite extensive, and it is open source. For example, you can use Google Map to display a location on a Google Map, which we will display on the website, or you can also display photos of your posts on Instagram, which you can integrate using the Instagram API.

3. API Partners

The partner type is similar to the public type, but it can be used when you have registered beforehand, which will provide a special key to access the service. And this type has special rules in it: to use their services, usually users who want to use them are required to pay a certain amount to get some access rights that have been granted by the owner, such as the number of requests, what data is allowed, etc.

4. Composite API

A composite type is an access right that can store data from various servers in one place. The advantage of having this access right will be several advantages and flexibility in data access, as well as saving time.


3. Get to know the architecture of API

API also has an architecture so that it has a strong foundation and can last a long time. There are at least 3 types of architecture, including:

1. RPC (Remote Procedure Call)

RPC is a technology used to assist client-side and server-side performance in communicating. There are 2 types of RPC, namely XML-RPC and JSON-RPC. The difference between these two types lies in the data transfer: XML-RPC uses files in the form of XML (Extensible Markup Language) to transfer data, while JSON-RPC uses JSON (JavaScript Object Notation) as a medium for data transfer.

2. REST (Representational State Transfer)

The use of REST architecture in the development process is quite popular among developers because REST does not require long and complex lines of code. REST forms data in the form of JSON, which has the advantage of being easy to understand and its light file size, which impacts application performance.

3. SOAP (Simple Object Access Protocol)

Unlike REST, which uses JSON, the other architecture is SOAP. Where the SOAP architecture forms data in the form of XML, this XML is a special document that will later be stored in the form of an XML document.


4. What are the benefits of the API?

As we explained earlier, many of the functions and uses of this method are felt by the developer.

1. Lighten up the server.

Its main function is to lighten server workload and improve server performance. By using this method, there is no need to search for data, all data is saved.

By simply calling data by accessing the endpoint on the URL, you can get the desired data from the originating server.

2. The process of making applications will be faster and more effective.

The good side of this method is that, in terms of application development, by connecting two different applications, communication between platforms will go much better. If you are developing a mobile application, you only focus on developing the mobile application.

The process of integration and adding features will be faster because there is no need to update manually, just with the help of this method.

3. Make the application functional.

The application will be more functional in adding certain information, you don't need to input it manually, and it can be handled easily. For example, in an application that requires courier postage costs, if you don't use this method, we will automatically input it manually from the courier's name, price, etc. There will be a problem when the price changes, and we have to enter it manually as well.

All related data will change automatically according to the data on the origin server, so the data displayed on the front-end will also change according to changes from the origin server.


What is a Web API and how does it work - difference web api and web services


5. What is the difference between a web API and a web service?

There are several other terms that we must understand to distinguish between a web API and a web service. A web API is an interface application system that aims to connect one application to another website-based application. A web service is a service provided through a website-based platform to connect different applications.

Differences between Web APIs and Web Services:

  • All web services use APIs, but not all APIs are used as web services.
  • Web services facilitate interaction between two devices or applications over a network. While the API acts as a liaison between two different applications so that they can communicate with each other or without a network,
  • Web services only use 3 types, namely SOAP, REST, or XML-RPC, to communicate, while APIs can use any type.
  • Web services require a network, while the API does not always require a network.


6. The difference between API, Rest API, and RESTful API

An API is an application interface that aims to connect one application to another. Rest API is a one-of-a-kind API itself. While the RESTful API is a REST client that accesses data on their respective REST servers, the differences in these resources can be distinguished from their URLs.


7. How to work and examples of the API

The way it works is that the application will communicate with an API itself and will receive requests from users for data to be displayed, and the server will provide responses, information, and data to the user.

An example that is widely used by other people is using this method to display the last few posts on their Instagram, along with user information such as followers, followings, profile pictures, etc., which will be displayed on the website.

Before using it, we must first register with the Instagram developer website to get access rights from the endpoint URL so that the data we want to display can run normally and according to the owner's rules. And after we get the endpoint, we can process the data that we want to display on the website automatically without having to think about the line-by-line of code because we already used it earlier.

The website will be prettier with the appearance of the last post and your Instagram account information, which will increase the professionalism of your website itself.



By understanding what the API is and how it works, it will make your development process faster and more effective without you having to create line-by-line code to fill the data itself. With this method, everything can be handled.