What Is an API? Architecture, Protocols, and Real-World Examples

A clear, zero-jargon explanation of what APIs are, how REST works under the hood, and how data moves between client and server.

Ekky Armandi6 min read

Photo by William Hook on Unsplash
Photo by William Hook on Unsplash

Most modern software feels like blackbox, what actually happen in the back, it relies on a massive network of applications silently sending messages back and forth. When you book a flight, pay for coffee with your phone, or ask an AI a question, you are using APIs.

If you are a non-technical founder or an operator working with engineering teams, understanding how these systems communicate is the first step to building scalable products.

In this article I will explain what an API actually is, the difference between the major architectural styles, and how data moves between a client and a server in the real world.

TLDR

  • The definition: An API allows two different software systems to talk to each other without knowing how the other is built.
  • The web standard: REST is the default architecture for web applications, relying on HTTP requests and JSON data.
  • Not a language: An API is not a programming language or a database. It is the messenger that sits between a database and a user interface.
  • Different tools for different jobs: Simple data fetching uses REST, real-time events use Webhooks, and high-speed streaming uses gRPC or WebSockets.

What is an API?

An Application Programming Interface (API) is a set of rules that allows one piece of software to communicate with another. It acts as a highly structured messenger.

If you go to a restaurant, you do not walk into the kitchen and cook your own meal. You look at a menu, make a choice, and give your order to a waiter. The waiter takes your request to the kitchen, the kitchen prepares the food, and the waiter brings it back to your table.

In software, your web browser is the customer, the database is the kitchen, and the API is the waiter.

sequenceDiagram
    participant Customer as Web Browser (Client)
    participant Waiter as API (The Messenger)
    participant Kitchen as Database (Server)

    Customer->>Waiter: Send data request
    Waiter->>Kitchen: Query the system
    Kitchen-->>Waiter: Return requested data
    Waiter-->>Customer: Deliver data payload

When people ask if an AI tool like ChatGPT is an API, the answer is no, but the company behind it provides an API. This means developers can send text directly to OpenAI’s servers and get a response back without having to build their own AI model. The API simply defines the exact format those messages must take.

The 4 fundamental API architecture styles

Different software systems need to communicate in different ways. Depending on the speed and complexity required, engineers typically choose one of four primary architectures.

REST (Representational State Transfer)

REST is the default standard for the web. It uses standard HTTP requests to fetch or modify data, usually formatted as JSON. It is stateless, meaning the server does not remember previous requests from the same user. Every time your mobile app loads a list of products or a user profile, it is likely making a REST API call.

Webhooks

If a REST API is like calling a store to ask if an item is in stock, a webhook is like asking the store to call you the moment a delivery arrives. Instead of constantly checking if a Stripe payment went through, your server sets up a webhook. Stripe automatically pushes the payment success event to your server the exact moment it happens.

GraphQL

GraphQL was created to solve the problem of over-fetching data in large applications. Instead of hitting five different REST endpoints to get a user’s profile, their recent orders, and their shipping address, GraphQL allows the client to ask for exactly what it needs in a single query. The server responds with only the requested data, saving bandwidth.

gRPC and WebSockets

When systems need to exchange massive amounts of data instantly, like in algorithmic trading platforms or live multiplayer games, REST is too slow. gRPC sends highly compressed binary data between servers, making internal microservice communication extremely fast. WebSockets take a different approach by keeping a connection permanently open, allowing for real-time bi-directional streaming between a browser and a server.

The anatomy of a REST API request

Every time a system talks to a REST API, it sends a highly structured message. To understand what backend developers actually build, you need to know the four key parts of this message.

The first part is the HTTP verb, which tells the server what action to take. A GET request retrieves data, a POST request creates new records, a PUT request updates existing ones, and a DELETE request removes them.

The second part consists of the headers. These are hidden key-value pairs that provide context about the request. The most common use for headers is authentication, where the client passes a secret API key or token to prove the user has permission to access the data.

The third part involves query parameters and JSON payloads. When you search for a product and filter by price, those filters get appended to the URL as query parameters. When you submit a form, the actual data is sent securely inside the JSON payload body.

Finally, the request results in a status code. When the server responds, it sends a three-digit code indicating what happened. A 200 means success, a 400 means the client sent badly formatted data, a 401 means the request lacked authentication, a 404 means the requested record was not found, and a 500 indicates the server crashed.

Client-server flow: What happens when you click checkout

To see how this works in practice, look at what happens under the hood when a user clicks a checkout button on an e-commerce site.

The web browser (the client) bundles the shopping cart data into a JSON payload and sends an HTTP POST request to the store’s backend API. The API receives the request, validates that the items are still in stock, and calculates the final price including taxes.

The store’s API then makes its own backend API call to a payment processor like Stripe, securely passing the credit card token and the charge amount. Stripe processes the card, returns a success message to the store’s API, and the store’s API finally sends a 200 OK response back to the user’s browser, triggering the order confirmation screen.

sequenceDiagram
    participant Browser as User's Browser
    participant StoreAPI as Store Backend API
    participant DB as Database
    participant Stripe as Stripe API

    Browser->>StoreAPI: POST /checkout (Cart payload)
    StoreAPI->>DB: Validate inventory
    DB-->>StoreAPI: Stock confirmed
    StoreAPI->>Stripe: Charge card token
    Stripe-->>StoreAPI: Payment Success (200 OK)
    StoreAPI->>DB: Save order record
    StoreAPI-->>Browser: Order Confirmation (200 OK)

This entire sequence happens in milliseconds. It involves three different systems built by different companies, but they work together perfectly because they all follow the same strict API contracts.

Where to go next

About the author

Ekky Armandi

Ekky Armandi is a full stack developer who builds custom web applications for founders and SMBs. He has shipped 100+ client projects over five years. On this blog he shares actionable guides on building software, tech architecture, and industry insights to help teams make smart software decision. Available for Hire

Back to Blog