Monday, September 21, 2026

What Is an API?

// software communication

What Is an API?

An API is an interface that allows one piece of software to interact with another. It defines how requests can be made, what information can be supplied and what results can be returned.

// definition

API means Application Programming Interface

API stands for Application Programming Interface.

An API provides a defined way for software systems, applications or components to communicate.

Instead of one program needing to understand the internal code of another program, it can communicate through the interface the API exposes.

// simple idea

An API is a controlled interface

Application A ↓ API ↓ Application B

Application A does not necessarily need access to the internal workings of Application B.

It only needs to know how to use the API correctly.

// example

Imagine a weather application

A website wants to display the current temperature in London.

Instead of measuring the weather itself, it can request information from a weather service.

Website ↓ Weather API ↓ Weather service ↓ Temperature data ↓ Website

The website can then display the information returned by the API.

// request + response

Many APIs use requests and responses

A client sends a request.

The API processes the request and sends a response.

Client ↓ Request ↓ API ↓ Processing ↓ Response ↓ Client

This request-response model is extremely common in web APIs.

// web api

Web APIs communicate over networks

Many modern APIs are accessed using HTTP or HTTPS, the same fundamental protocols used by websites.

https://api.example.com/products

Software can send an HTTP request to this address and receive structured information in return.

// endpoint

What is an API endpoint?

An endpoint is a particular location exposed by an API for performing an operation or accessing a resource.

/products /products/42 /customers /orders

Different endpoints can provide access to different types of information or functionality.

// http methods

HTTP methods describe the intended operation

Method Common purpose
GET Retrieve information
POST Submit or create information
PUT Replace or update a resource
PATCH Partially update a resource
DELETE Remove a resource

The exact meaning depends on the API's design.

// get

GET can retrieve information

GET /products/42

The API might return:

{ "id": 42, "name": "Keyboard", "price": 39.99 }
// post

POST can send information

A client might create a new customer by sending:

POST /customers

with data such as:

{ "name": "Alice", "email": "alice@example.com" }

The server can validate the information, store it and return a response.

// json

APIs commonly use JSON

JSON is a convenient format for exchanging structured information between software systems.

{ "customer": { "id": 101, "name": "Alice", "active": true } }

A client can parse this data and use the individual values in its own application.

// data formats

APIs do not have to use JSON

Depending on the system, an API may exchange data using:

JSON XML HTML Plain Text Binary Data
// parameters

Requests can include parameters

Parameters allow the client to specify what it wants.

GET /weather?city=London

Here:

city=London

provides additional information to the API.

// headers

HTTP requests can contain headers

Headers carry metadata about a request or response.

Content-Type: application/json Authorization: Bearer TOKEN

Headers can specify things such as data format, authentication information and caching behaviour.

// authentication

Many APIs require authentication

An API may need to know which application or user is making a request.

Common approaches include:

API Keys Access Tokens OAuth Sessions Signed Requests

API credentials should be protected. Private keys and tokens should not normally be exposed publicly in website source code or public repositories.

// api key

What is an API key?

An API key is a value that can identify an application or account when making API requests.

API-Key: abc123...

The service can use the key to determine who is making the request and which permissions or usage limits apply.

// status codes

Web APIs often return HTTP status codes

Code General meaning
200 Request succeeded
201 Resource created
400 Problem with the request
401 Authentication required or invalid
403 Request understood but not permitted
404 Resource not found
429 Too many requests
500 Server-side error
// javascript

JavaScript can call web APIs

fetch("https://api.example.com/products") .then(response => response.json()) .then(data => { console.log(data); });

The browser sends the request, receives the response and converts the JSON into JavaScript data.

// server-side code

Server-side software can also use APIs

PHP, Python, JavaScript, Java, C# and many other languages can communicate with APIs.

Application ↓ API request ↓ External service ↓ API response ↓ Application

APIs allow systems written in completely different programming languages to work together.

// database

An API can sit between an application and a database

Website ↓ API ↓ Server application ↓ Database

The website does not need direct access to the database.

Instead, the API exposes specific operations while the server controls how the underlying data is accessed.

// controlled access

APIs can control what software is allowed to do

An application may be allowed to:

Read Products Create Orders Update Profiles Upload Files

while being prevented from directly accessing internal systems or performing unauthorised operations.

// rate limits

APIs can limit how frequently they are used

A service might allow:

1,000 requests per day

or:

100 requests per minute

These restrictions are called rate limits.

// rest

What is a REST API?

REST stands for Representational State Transfer.

It describes an architectural style for designing networked systems.

APIs described as RESTful commonly organise operations around resources and use HTTP methods such as GET, POST, PUT, PATCH and DELETE.

API and REST API are not synonyms. REST is one approach to API design. APIs can use many other architectures and protocols.

// other api styles

APIs can use different technologies

REST GraphQL SOAP RPC WebSockets

The best approach depends on the systems involved and what they need to communicate.

// important distinction

Not every API is a web API

The term API is broader than internet services.

Programming languages, operating systems, libraries and software frameworks can all expose APIs.

Browser API Operating system API Database API JavaScript API Web API Library API

In each case, the API defines how another piece of software can interact with the system.

// examples

What can APIs connect?

Payments

A website can communicate with a payment service.

Maps

An application can retrieve maps or location data.

AI

Software can send prompts or data to an AI service.

Email

Applications can send or manage messages through email services.

Accounting

Business systems can exchange invoices, transactions or customer information.

Automation

One service can trigger actions in another system.

// automation

APIs make automation possible

Suppose a customer submits an online order.

Order received ↓ Payment API ↓ Database ↓ Email API ↓ Accounting API ↓ Order completed

Multiple systems can communicate automatically without someone manually copying the information between them.

// contract

An API behaves like a software contract

The API documentation defines how another program is expected to interact with the system.

It might specify:

Endpoints Methods Parameters Authentication Data Formats Responses Errors Rate Limits

As long as both systems follow the agreed interface, their internal implementations can often change without requiring the other system to understand those details.

// advantages

Why are APIs so useful?

Integration

Different software systems can work together.

Automation

Information can move between systems automatically.

Abstraction

Applications can use functionality without knowing every internal implementation detail.

Reuse

The same service can support websites, mobile apps, internal tools and other software.

// mental model

The simplest way to think about an API

Your software ↓ "Please do this" ↓ API ↓ Other software ↓ Result ↓ Your software

The API defines the rules for that conversation.

// summary

Software talking to software.

An API is an Application Programming Interface: a defined way for software systems to interact. APIs can expose data and functionality through requests, responses, endpoints and documented rules, making them fundamental to integrations, automation, websites, applications and modern software systems.

What Is Python?

// programming What Is Python ? Python is a high-level, general-purpose programmi...