API

AApplication
PProgramming
IInterface

An API is an interface that allows other programs to use functionality or data that you expose — without knowing how it is implemented.

In terms of distributed systems, an “API” usually means a Web API: an interface that is used over a network.


API use cases


  1. Frontend ↔ Backend – your web or mobile app loads and stores data on the server.
  2. Service ↔ Service – components of a distributed system talk to each other.
  3. External services – weather, maps, payment, login, AI … (Data as a Service).

Software parts written in different languages can work together — as long as they agree on the same interface and the same protocol.


Example: weather data

Request:

GET https://www.7timer.info/bin/astro.php?lon=15.593063&lat=48.411018&ac=0&unit=metric&output=json

Response:

HTTP/1.1 200 OK
Content-Type: application/json
 
{
  "product": "civil",
  "init": "2023070206",
  "dataseries": [
    { "cloudcover": 7, "temp2m": 21, "rh2m": "63%",
      "wind10m": { "direction": "W", "speed": 3 } },
    ...
  ]
}

Try it: paste the URL into your browser or run curl -i "<url>".


Many words – what is what?

“It’s a REST API that uses HTTP and JSON, described with OpenAPI.” These words are not alternatives — they describe different layers:


LayerQuestionExamples
API descriptionHow is the API documented?OpenAPI, AsyncAPI, .proto
Architectural styleHow is the API designed?REST, RPC, GraphQL, event-driven
Data formatHow is the content encoded?JSON, XML, Protobuf
Application protocolWhich messages are exchanged?HTTP, WebSocket, MQTT
TransportHow do the bytes get there?TCP, UDP, QUIC

Protocol vs. architectural style

Protocols …

  • define exactly how two processes exchange messages (format, meaning, order).
  • work between processes on different machines over a network.
  • are open to any technology or programming language.
  • have a clear, written specification (e.g. an RFC).

Architectural styles …

  • are design rules / ideas for building an API on top of a protocol.
  • have no strict specification — you can follow them more or less well.

ProtocolArchitectural style
ExamplesHTTP, WebSocket, MQTTREST, RPC, event-driven
Violate it?it doesn’t workit works, but it’s not that style
Analogygrammar of a languagewriting style (letter, poem, news)

🔑 REST is not a protocol — it is a way of designing an API that uses the HTTP protocol.


Ways of providing an API


REST

  • Architectural style (Roy Fielding, 2000) — built on HTTP.
  • Everything is a resource with its own URL; you use HTTP methods on it.
GET    /students/42
DELETE /students/42
  • Use: the default for most web APIs — simple, widely supported, cacheable.

GraphQL

  • Query language for APIs (Facebook, 2015) — usually one endpoint over HTTP.
  • The client decides which fields it wants.
{ student(id: 42) { name grades { subject value } } }
  • Use: frontends that need flexible data from many sources in one request.

gRPC

  • RPC framework (Google, 2015) — call functions on a remote server like local ones.
  • Contract in a .proto file, binary Protobuf messages over HTTP/2.
  • Use: fast, strongly typed communication between services (microservices).

SOAP

  • XML-based messaging protocol (W3C), usually over HTTP; described with WSDL.
  • Use: older enterprise and government systems (banks, insurance) — you will still meet it.

WebSocket

  • Protocol for a permanently open, bidirectional connection (starts as HTTP).
  • Use: real-time data — chat, live scores, multiplayer games, dashboards.

Webhooks

  • A pattern, not a protocol: the provider sends an HTTP POST to your URL when something happens.
  • Use: notifications — “payment received”, “new commit pushed”.

Message brokers (MQTT, AMQP, Kafka)

  • Publish/subscribe: senders publish to a topic, receivers subscribe (→ Distributed-Systems).
  • Use: IoT (MQTT), decoupled background processing, event streaming.

MCP – Model Context Protocol

  • Open protocol (Anthropic, 2024) based on JSON-RPC.
  • Lets AI applications (e.g. Claude, ChatGPT, IDE assistants) connect to external tools and data in a standardised way.
  • An MCP server exposes tools, resources and prompts; the AI app is the client.
  • Use: give an AI model access to your files, databases or APIs — “a USB-C port for AI”.

Overview

NameWhat is it?Runs onFormatTypical use
RESTarchitectural styleHTTPmostly JSONweb APIs
GraphQLquery language + specHTTPJSONflexible frontends
gRPCRPC framework / protocolHTTP/2Protobufservice ↔ service
SOAPmessaging protocolHTTPXMLlegacy enterprise
WebSocketprotocolTCPtext / binaryreal-time
WebhookspatternHTTPmostly JSONevent notifications
MQTT / AMQPprotocols (pub/sub)TCPanyIoT, messaging
MCPprotocolJSON-RPC over stdio / HTTPJSONAI ↔ tools

Usage

From the Postman State of the API Report 2025:


Summary

  • An API is an interface for programs; a Web API is used over the network.
  • Keep the layers apart: transport → protocol → data format → style → description.
  • Protocols (HTTP, WebSocket, MQTT, MCP …) are strict message specifications.
  • Architectural styles (REST, RPC, event-driven …) are design ideas on top of protocols.
  • REST, GraphQL and gRPC all usually travel over HTTP — they differ in design.

Check your understanding

  1. Explain the difference between a protocol and an architectural style. Give two examples of each.
  2. What is wrong with the sentence “Our API uses REST instead of HTTP”?
  3. Assign each term to its layer: TCP, REST, JSON, HTTP/2, OpenAPI, Protobuf, MQTT, QUIC.
  4. Which technology would you choose — and why?
    • a chat app that shows new messages instantly
    • 50 internal microservices that call each other thousands of times per second
    • temperature sensors in every classroom
    • an AI assistant that should be able to read your school’s timetable