API

- Reading time: 3 minutes -

API

An interface for programming applications is called an “API” (Application Programming Interface). So a programming interface. However, a “REST API” is not a leftover interface, but also “REST” is an abbreviation for “Representational State Transfer”. “REST API” is more or less a term for how the communication between client and server (i.e. two machines) typically looks/works.

… if you want to read more theory, Wikipedia (external) and friendventure.de - what is REST API? are very good places - but how does it look technically, when the youth of today builds client-server services, and likes to use HTTP for that?

Practical example “Ordering system in a café”:

The waitress takes an order, her app then sends e.g. the following JSON data via HTTP to https://das-cafe.de/api/bestellung:

{"id": 12345,
 "table": 42,
 "items": [
 { "name": "cappucino",
   "decaf": true},
 { "name": "cheesecake",
   "cream": false}]}

Typically, the server then responds with at least “ok” or “failed because […]“. Depending on the service (e.g. Matrix), other (JSON) data may also come back.

In the end, you pay and the app sends corresponding data to https://das-cafe.de/api/bezahlung.

So on the web server side there is code that expects JSON data with certain fields under /api/order and /api/payment respectively and does smart things with it. This is comparable to functions of a library in any programming language. The “API” (= interface) of such a library would be that it offers the functions order(42, ["cappucino", ...]), payment(42)etc. If the call happens via HTTP instead, as in the café, it’s called a “REST API”. The provider of the café solution builds a service, comes up with a REST API, and documents it for app developers on the provider’s website.

Unlike interfaces (APIs), which anyone can describe and publish for their product and software, international standardized protocols such as those developed by the IETF are published Internet standards.