DEV Community

Cover image for APi (application programming interface ) to be discuss
Sundar Joseph
Sundar Joseph

Posted on

APi (application programming interface ) to be discuss

What is an API?
An API is a set of rules that allow different software applications to communicate with each other. Think of it like a bridge that connects two systems and lets them share data or services.

To make this clearer, let's use an example:

Imagine you're at a restaurant. The waiter (API) takes your order (request), brings it to the chef (server), and then brings the food back to you (response).
Similarly, when you search for a course on a website, you send a request through an API, which then checks the database and sends the result back to you.
APIs are the building blocks for the todays websites in which heavy data is transferred from the client to server and vice versa. If you want to learn such more concepts of the websites then you should enrol in our Full Stack Node Development Course

Why Do We Need APIs?
APIs help developers to create software programs more easily. Instead of writing complex code from scratch, they can call APIs that already provide the functions they need. For example, if a developer wants to display a weather report, they can use an API to get the data instead of creating the entire system to gather weather data themselves.

APIs are also crucial in building modern websites, where heavy data transfers happen between the client (user) and the server.

How Do APIs Work?
APIs work in a simple step-by-step process:

Request: A client (user) sends a request through the API's URI (Uniform Resource Identifier).
Processing: The API forwards the request to the server.
Response: The server processes the request and sends the response back to the API.
Delivery: The API returns the server's response to the client.
Think of this as a client-server architecture: the client sends a request, the server processes it, and the API acts as the messenger.curity threats. To provide additional security layers to the data, HTTP headers, query string parameters, or cookies are used.

Types of API Architectures:
REST (Representational State Transfer) :A simple, flexible API architecture that uses HTTP methods (GET, POST, PUT, DELETE) for communication.
SOAP (Simple Object Access Protocol) :A more rigid protocol that requires XML-based messaging for communication.
Both define a standard communication protocol for the exchange of messages in XML (Extensible Markup Language).

How is an API Different From a Web Application?
An API acts as an interface that allows proper communication between two programs whereas a web application is a network-based resource responsible for completing a single task. Also, it's important to know that "All web services are APIs, but not all APIs are web".

The difference between an API and a web application is that API allows two-way communication and web applications are just a way for users to interact through a web browser. A web application may have an API to complete the requests.

Types of APIs
There are three basic forms of API -

  1. WEB APIs
    A Web API also called Web Services is an extensively used API over the web and can be easily accessed using the HTTP protocols. A Web application programming interface is an open-source interface and can be used by a large number of clients through their phones, tablets, or PCs.

  2. LOCAL APIs
    In this type of API, the programmers get the local middleware services. TAPI (Telephony Application Programming Interface), and .NET are common examples of Local APIs.

  3. PROGRAM APIs
    It makes a remote program appear to be local by making use of RPCs (Remote Procedural Calls). SOAP is a well-known example of this type of AP

Top comments (0)