Skip to main content

Why are APIs so important?

This is a common example which is used to give the introduction to APIs - think of it as a waiter in a restaurant: you (the application) tell the waiter what you want from the kitchen (another application). The waiter (the API) takes your request, communicates it to the kitchen, and then brings the response (your food) back to you. You don't need to know how the kitchen operates, just how to order from the menu.

APIs, or Application Programming Interfaces, act as a contract for communication between different software systems. They allow one piece of software (the client) to request services or data from another piece of software (the server or service provider) in a defined and structured way, without needing to know the internal workings of the other system. They are essentially a set of protocols that govern how software applications should interact.

Now below I have discussed about the basics of APIs: types(web APIs and other types) and about the components of APIs.



API Types

APIs are categorized based on their architecture, scope, or the level of access they provide.

Web APIs

Web APIs enable communication over the internet using the HTTP/HTTPS protocol, allowing systems running on different machines to exchange data.

  • REST APIs (Representational State Transfer):

    • Architecture: A set of architectural constraints, not a protocol. It uses standard HTTP methods (GET, POST, PUT, DELETE, etc.) to perform operations on resources.

    • Data Format: Typically uses JSON or XML for data transfer.

    • Key Concept: Focuses on resources (e.g., a user, a product) which are identified by URLs (endpoints). They are stateless, meaning each request from a client to the server contains all the information needed to understand the request.

    • Usage: The most common type of API used for web services, mobile apps, and microservices.

  • SOAP APIs (Simple Object Access Protocol):

    • Protocol: A protocol defined by the W3C (World Wide Web Consortium). It is more rigid and standardized than REST.

    • Data Format: Strictly uses XML for messages (called Envelopes).

    • Key Concept: Requires a detailed contract (called a WSDL - Web Services Description Language document) that describes all available operations and data structures. It is often used where high security, transaction integrity, and formal contracts are necessary.

    • Usage: Historically used in enterprise environments, financial services, and telecommunications.

  • GraphQL APIs (Graph Query Language):

    • Query Language/Runtime: An API architecture developed by Facebook. It is a data querying language and a server-side runtime for executing those queries.

    • Key Concept: The client specifies exactly the data it needs, and nothing more. This eliminates over-fetching (getting more data than necessary) and under-fetching (requiring multiple requests for related data) common in REST. The API structure is often represented as a graph of data.

    • Usage: Modern web and mobile applications where data efficiency and flexibility are critical.

Other API Types

APIs are not limited to the web; they exist at every level of the software and hardware stack.

  • DBMS (Database Management System) APIs:

    • These APIs allow applications to interact with a database. Examples include JDBC (Java Database Connectivity) and ODBC (Open Database Connectivity). They provide functions to connect to the database, execute SQL queries (like SELECT, INSERT), and retrieve results.

  • OS (Operating System) APIs:

    • These APIs (often called System Calls) allow applications to request services from the operating system kernel. They provide access to fundamental functions like managing files, allocating memory, creating processes/threads, and handling I/O (input/output). Examples include the Win32 API (for Windows) or POSIX system calls (for Linux/Unix).

  • Hardware APIs:

    • These APIs allow software to communicate directly with or control a specific piece of hardware. For example, a graphics card API like DirectX or OpenGL allows a video game to instruct the GPU (Graphics Processing Unit) to render 3D images. Other examples include APIs for controlling camera sensors, printers, or networking cards.

  • Library / Framework APIs:

    • These are the APIs you use when writing code with a particular library or framework. For instance, the Python requests library API provides methods (.get(), .post()) to easily make HTTP calls. The React framework API provides components and lifecycle methods for building user interfaces. They expose the functionality of the underlying code to the developer.


API Components

These are the essential building blocks that make up a typical Web API interaction.

  • Endpoint:

    • What it is: The specific URL where an API service is hosted and can be accessed. It is the target of the request.

    • Structure: In a REST API, an endpoint is typically a combination of the base URL and a specific path that identifies a resource.

    • Example: https://api.example.com/v1/users or https://api.example.com/v1/products/42.

  • Request:

    • What it is: The message sent from the client (the requesting application) to the server (the API).

    • Components: A request must include an Endpoint (where to go), a Method (what to do), and often includes Headers (metadata like authorization) and a Body (data to send, e.g., for creating a new user).

  • Methods (HTTP Verbs):

    • What they are: Standardized actions that specify the desired operation on the resource identified by the endpoint.

    • Common Methods (REST):

      • GET: Retrieve data from the server.

      • POST: Submit data to the server, often creating a new resource.

      • PUT: Update a resource or replace it entirely.

      • PATCH: Partially update a resource.

      • DELETE: Remove a resource.

  • Response:

    • What it is: The message sent back from the server to the client after processing the request.

    • Components: A response includes a Status Code (e.g., 200 OK, 404 Not Found, 500 Internal Server Error) to indicate the outcome of the request, Headers, and a Body containing the requested data or a success/error message.

Popular posts from this blog

Programming Without and With AI

👀Programming Without AI refers to traditional software development, where a computer program is designed to perform a specific set of tasks based on explicit rules coded by the programmer. Traditional  programming without AI relies on explicit rules and instructions written by humans. Every possible situation has to be anticipated in advance, and the program follows fixed logic to produce results.  In contrast, programming with AI allows systems to learn from data, adapt to new situations, and improve over time . The image below illustrates the fundamentals of AI, showing how it expands from general Artificial Intelligence into Machine Learning, Neural Networks, and Deep Learning , each adding more advanced capabilities. AI Layers Explained This layered structure highlights how modern AI has moved beyond simple rule-based systems into powerful learning models capable of tasks such as image recognition, natural language processing, and autonomous decision-making.  👀 Bef...

.NET Ecosystem Overview - Roadmap

In this blog series we'll discuss about a roadmap to learn .NET framework. There are 10 stages in this roadmap below I have listed the stages which will guide you when learning this framework; 🌐Introduction to the .NET Framework The .NET Framework is Microsoft’s powerful software development platform, first released in 2002 . Back then, building applications was often messy—developers had to deal with different programming languages, inconsistent APIs, and limited tools. Microsoft’s vision was simple: create a single, unified platform where developers could build desktop apps, web apps, and services using a common foundation. Over the years, .NET has evolved dramatically. It started with the classic .NET Framework , then moved to the open-source and cross-platform .NET Core , and finally merged into today’s modern .NET 5, 6, and beyond , which powers apps on Windows, Linux, macOS, mobile, and even cloud containers. Real-world apps built on .NET include Stack Overflow, Microsof...

How is a CPU Made? Step-by-Step Guide to Microchip Production

Making a CPU, which is the brain of a computer, is a very complex process. It starts with the design. Designers decide how the CPU will work, including how many cores it has and how fast it can process information. Before building it, they use computer programs to test the design and make sure it works correctly. We mainly use silicon as the raw material for the production process. Silicon is a material that comes from sand and can carry electricity when treated in certain ways, as it is a semi conductor . Now  lets dive into the production process of the microchip➡️ 🥇The silicon is purified and shaped into a large cylinder called an ingot . This cylinder is then sliced into very thin discs called wafers, which will become the base for all the CPU circuits. 🥈After that comes photolithography . This is a process where the CPU’s design is printed onto the wafer using light. A special chemical called photoresist is applied to the wafer, which reacts to light. The light makes certain...