Showing posts with label Automation. Show all posts
Showing posts with label Automation. Show all posts

Monday, September 21, 2026

What Is Python?

// programming

What Is Python?

Python is a high-level, general-purpose programming language known for readable syntax and a large ecosystem of libraries. It is widely used for automation, data processing, web development, artificial intelligence, APIs and many other programming tasks.

// definition

Python is a programming language

Python is a general-purpose programming language used to express instructions that computers can execute.

It is designed around relatively clear and concise syntax, allowing many programs to be expressed with comparatively little code.

Python can be used for small scripts as well as much larger software systems.

// hello world

A Python program can be extremely simple

print("Hello, world!")

The print() function sends the text to the program's output.

Hello, world!
// files

Python source files normally use .py

hello.py automation.py data_cleaner.py api_client.py

These files contain Python source code written as plain text.

// variables

Python can store values in variables

name = "Freelance Coder" price = 25.50 quantity = 4 active = True

The variable name provides a way for later instructions to refer to the stored object.

// data types

Python has many built-in data types

Type Example
str "Hello"
int 42
float 3.14
bool True
list [1, 2, 3]
dict {"name": "Tiago"}
tuple (1, 2)
set {1, 2, 3}
NoneType None
// dynamic typing

Python is dynamically typed

A variable name does not have to be declared with a fixed type before it is used.

x = 10 x = "hello"

In this example, the name x first refers to an integer and later refers to a string.

The objects still have types. Dynamic typing means Python determines and checks those types at runtime rather than requiring every variable declaration to specify one in advance.

// operators

Python can perform calculations

a = 10 b = 3 a + b a - b a * b a / b a ** b a % b

These operators perform addition, subtraction, multiplication, division, exponentiation and remainder operations.

// lists

Lists store ordered collections

languages = [ "Python", "JavaScript", "PHP" ]

Python list indexes begin at zero.

languages[0] # "Python"
// dictionaries

Dictionaries store key-value relationships

product = { "name": "Keyboard", "price": 39.99, "stock": 12 }

Individual values can be retrieved using their keys.

product["price"] # 39.99
// conditions

Python can make decisions

age = 20 if age >= 18: print("Adult") else: print("Under 18")

The program follows different instructions depending on whether the condition is true or false.

// indentation

Indentation is part of Python syntax

Many programming languages use braces to group blocks of instructions.

Python uses indentation.

if temperature > 20: print("Warm") print("Open the window") print("Finished")

The two indented instructions belong to the if block.

Whitespace can therefore affect program meaning. Indentation is not merely visual formatting in Python.

// loops

Loops repeat instructions

for number in [1, 2, 3]: print(number)

Output:

1 2 3
// range

range() is useful for repeated operations

for i in range(5): print(i)

This produces:

0 1 2 3 4
// functions

Functions package reusable behaviour

def add(a, b): return a + b result = add(5, 7) print(result)

Output:

12

Functions help divide larger programs into smaller, reusable pieces.

// classes

Python supports object-oriented programming

class Product: def __init__(self, name, price): self.name = name self.price = price product = Product( "Keyboard", 39.99 )

Classes can define objects that combine data and behaviour.

// modules

Programs can be divided into modules

Python code stored in separate files can be imported and reused.

import math result = math.sqrt(25) print(result)

Output:

5.0
// standard library

Python includes a large standard library

A Python installation includes modules for many common programming tasks.

Files JSON CSV SQLite Dates Regular Expressions Networking ZIP Files
// packages

Additional libraries can be installed

Python has a very large ecosystem of third-party packages.

Packages are commonly installed using pip.

pip install requests

The package can then be imported into a Python program.

import requests
// environments

Projects can use virtual environments

Different projects may depend on different package versions.

A virtual environment creates an isolated Python environment for a project.

python -m venv .venv
Project A ↓ Environment A ↓ Its packages Project B ↓ Environment B ↓ Different packages
// file handling

Python can read and write files

with open( "example.txt", "r", encoding="utf-8" ) as file: text = file.read() print(text)

This makes Python useful for processing large numbers of files automatically.

// csv

Python can process CSV data

import csv with open( "customers.csv", encoding="utf-8", newline="" ) as file: rows = csv.reader(file) for row in rows: print(row)

CSV processing is useful for spreadsheets, exports, reports and data cleaning.

// json

Python works naturally with JSON

import json text = '{"name": "Alice", "active": true}' data = json.loads(text) print(data["name"])

Output:

Alice
// databases

Python can communicate with databases

Python's standard library includes support for SQLite, and third-party packages can connect to many other database systems.

Python ↓ SQL ↓ Database ↓ Rows of data
SQLite PostgreSQL MySQL SQL Server
// sqlite example

Python can create a SQLite database

import sqlite3 connection = sqlite3.connect( "products.db" ) cursor = connection.cursor() cursor.execute(""" CREATE TABLE IF NOT EXISTS products ( id INTEGER PRIMARY KEY, name TEXT, price REAL ) """) connection.commit() connection.close()
// apis

Python can communicate with APIs

A Python application can send HTTP requests and process the returned information.

Python program ↓ HTTP request ↓ API ↓ JSON response ↓ Python data

A third-party library such as requests is commonly used for this.

import requests response = requests.get( "https://api.example.com/products" ) data = response.json()
// automation

Python is particularly useful for automation

A Python script can perform repetitive technical tasks without someone manually completing each step.

Read files ↓ Clean data ↓ Call API ↓ Update database ↓ Create spreadsheet ↓ Generate report
// spreadsheets

Python can work with Excel files

Libraries such as openpyxl can read, create and modify .xlsx workbooks.

from openpyxl import Workbook workbook = Workbook() sheet = workbook.active sheet["A1"] = "Product" sheet["B1"] = "Price" workbook.save( "products.xlsx" )

This can automate spreadsheet reporting and data processing.

// data

Python is widely used for data work

Data Cleaning Data Analysis Statistics Visualisation Spreadsheets Databases

Libraries such as NumPy and pandas provide additional tools for numerical and tabular data processing.

// artificial intelligence

Python is widely used in AI and machine learning

Many machine-learning and artificial-intelligence libraries provide Python interfaces.

Machine Learning Neural Networks Natural Language Processing Computer Vision

Python's role here is strengthened by its extensive scientific and data-processing ecosystem.

// web development

Python can run web applications

Python can execute on a server and generate website responses.

Browser ↓ HTTP request ↓ Python web application ↓ Database / APIs ↓ HTTP response ↓ Browser

Python web frameworks include technologies such as Django, Flask and FastAPI.

// python vs javascript

Python and JavaScript often run in different places

Python JavaScript
Commonly runs on servers or computers Runs directly in web browsers
Strong data and automation ecosystem Core language of browser interactivity
Can build back-end web services Can build front-end and back-end applications

Both languages are general-purpose enough to overlap in many areas.

// execution

How does Python code actually run?

The most widely used Python implementation is CPython.

In simplified form, CPython processes source code, compiles it into Python bytecode and executes that bytecode using its interpreter.

Python source code ↓ Compilation ↓ Python bytecode ↓ Python virtual machine ↓ Program executes

Calling Python simply "interpreted" is useful but incomplete. Python implementations can use different execution techniques. CPython normally compiles source code to bytecode before executing it.

// interactive shell

Python can also be used interactively

Python provides an interactive environment where instructions can be entered one at a time.

>>> 2 + 3 5 >>> "hello".upper() 'HELLO'

This makes it convenient for experimentation, calculations and testing small pieces of code.

// readability

Python emphasises readable syntax

Compare the structure of a simple condition:

if balance > 0: print("Positive balance")

Keywords such as if, for, in, def and return make much Python code relatively close to structured written instructions.

// uses

What is Python used for?

Automation

Repetitive computer tasks can be scripted.

Data

Files, spreadsheets and databases can be processed.

APIs

Programs can communicate with external services.

Web Development

Python can power server-side web applications.

AI

Python is widely used with machine-learning tools.

Scientific Computing

Numerical and scientific libraries support research and technical computing.

// practical example

One script can connect several technologies

CSV file ↓ Python ↓ Clean data ↓ SQLite database ↓ API request ↓ Create XLSX report ↓ ZIP output files

This ability to connect different formats, systems and services is one reason Python is particularly useful for automation and data-management work.

// mental model

The simplest way to think about Python

Data ↓ Python instructions ↓ Logic + calculations ↓ Files / APIs / databases ↓ Useful result

Python provides a language for describing the operations a computer should perform.

// summary

Instructions become automation.

Python is a high-level, general-purpose programming language with readable syntax and a large software ecosystem. It can work with files, spreadsheets, databases, APIs and websites, and is widely used for automation, data processing, scientific computing, artificial intelligence and software development.

What Is a ZIP File?

// file formats

What Is a ZIP File?

A ZIP file is an archive file that can combine multiple files and folders into a single package. It can also compress the data inside, reducing the amount of storage space required and making collections of files easier to transfer.

// definition

ZIP is an archive format

A ZIP file is an archive that can contain one or more files and directories.

The contents can be stored together inside a single file ending in the .zip extension.

ZIP also supports lossless compression, allowing many types of data to be stored using fewer bytes.

// example

Several files can become one archive

Suppose a folder contains:

project/ │ ├── index.html ├── styles.css ├── script.js └── logo.png

The entire folder could be packaged as:

project.zip

Instead of sending four separate files and their folder structure, you can send a single archive.

// archive

ZIP preserves files and folders together

A ZIP archive can preserve directory structure.

website.zip │ ├── index.html │ ├── css/ │ └── styles.css │ ├── js/ │ └── app.js │ └── images/ └── logo.png

When the archive is extracted, the original folder structure can be recreated.

// compression

ZIP files can compress data

Compression attempts to represent the same information using fewer bytes.

Original files ↓ Compression ↓ Smaller ZIP archive

The amount saved depends heavily on the type of data being compressed.

// lossless

ZIP compression is lossless

Lossless compression means the original information can be reconstructed exactly when the archive is decompressed.

Original file ↓ Compress ↓ ZIP data ↓ Extract ↓ Original file restored

No content needs to be deliberately discarded. This is different from lossy formats that may remove information to achieve smaller file sizes.

// file size

Not every file becomes much smaller

Text-based files often compress very effectively because they can contain repeated patterns.

TXT CSV XML HTML JSON

Files that are already compressed may shrink very little.

JPEG MP3 MP4 PNG

In some cases, placing already compressed data inside a ZIP archive may produce almost no size reduction.

// storage

ZIP can also store files without compression

A ZIP archive does not require every file inside it to be compressed.

Entries can also be stored directly while still benefiting from the archive structure.

ZIP archive │ ├── file1.txt → compressed ├── photo.jpg → stored └── video.mp4 → stored
// extraction

What does "extract" mean?

Extracting a ZIP file means taking files out of the archive and restoring them as ordinary files and folders.

project.zip ↓ Extract ↓ project/ ├── index.html ├── styles.css └── script.js

The ZIP archive itself can remain unchanged after extraction.

// creating

What does "zip" a folder mean?

To zip files means to package them inside a ZIP archive.

Folder ↓ Create ZIP archive ↓ folder.zip

Operating systems such as Windows and macOS include built-in tools for creating and extracting ZIP archives.

// internal structure

A ZIP file contains multiple file records

Internally, ZIP stores information about the files inside the archive.

This can include:

File Names Folder Paths Compressed Data File Sizes Checksums Timestamps
// directory

ZIP files contain a central directory

A ZIP archive normally contains a central directory describing the entries stored inside it.

ZIP archive │ ├── File data ├── File data ├── File data │ └── Central directory ├── file names ├── locations ├── sizes └── metadata

Software can use this information to find and list the archive's contents.

// integrity

ZIP files can detect some forms of corruption

ZIP entries commonly include a CRC-32 checksum.

The checksum can be used to check whether extracted data matches the data expected by the archive.

Stored checksum ↓ Extracted file ↓ Calculate checksum ↓ Compare values
// encryption

ZIP archives can be password-protected

Some ZIP tools support encryption so that the archive contents cannot be read without the required password.

Password protection and compression are different things. Compression reduces or packages data. Encryption is intended to protect data from unauthorised access.

// container format

ZIP is also used as a container for other file formats

Some file formats are actually specialised ZIP packages.

Format What it contains
.xlsx Excel workbook XML and supporting files
.docx Word document XML and supporting files
.pptx PowerPoint XML and supporting files

These formats use ZIP as the underlying package containing multiple structured files.

// xlsx example

An .xlsx file is a specialised ZIP package

workbook.xlsx ↓ ZIP package ↓ xl/ ├── workbook.xml ├── styles.xml └── worksheets/ └── sheet1.xml

This is why renaming a copy of an .xlsx file to .zip can allow ZIP software to inspect its internal structure.

// zip vs folder

A ZIP archive is not the same as a normal folder

Folder ZIP archive
Directory on a file system Single archive file
Contains files directly Packages entries inside the archive
No compression by itself Can compress contained files
Easy to edit directly Usually extracted or modified with archive software
// archive formats

ZIP is one of several archive formats

ZIP RAR 7Z TAR GZIP

These formats have different features, compression methods and levels of software support.

ZIP is particularly widespread because support is built into many operating systems and applications.

// programming

Software can create ZIP files automatically

Programming languages can create, inspect and extract ZIP archives.

Python PHP JavaScript Java C#
// python example

Python can create ZIP archives

import zipfile with zipfile.ZipFile( "project.zip", "w", zipfile.ZIP_DEFLATED ) as archive: archive.write("index.html") archive.write("styles.css")

The program creates an archive and adds files to it.

// automation

ZIP files are useful in automated workflows

Generate files ↓ Create ZIP ↓ Upload archive ↓ Send to customer ↓ Customer extracts files

This makes ZIP useful for exports, backups, downloadable packages and batch processing.

// backups

ZIP files are commonly used for backups

A group of related files can be bundled into one archive:

website-backup.zip │ ├── html/ ├── css/ ├── images/ ├── scripts/ └── data/

This makes the collection easier to copy, store and transfer.

// transfer

ZIP files make collections easier to send

Instead of attaching twenty separate files to a message, they can be placed inside one archive.

20 files ↓ project.zip ↓ 1 attachment
// security

ZIP files should still be treated carefully

A ZIP archive can contain almost any type of file, including executable programs and scripts.

Receiving a file inside a ZIP archive does not make that file automatically safe.

Only extract and run files from sources you trust. An archive is simply a container and does not guarantee that its contents are harmless.

// uses

What are ZIP files used for?

File Transfer Compression Backups Software Downloads Website Files Data Exports Document Packages Automation Archiving
// mental model

The simplest way to think about a ZIP file

Files + folders ↓ Package together ↓ Optional compression ↓ archive.zip ↓ Transfer or store ↓ Extract ↓ Original files + folders
// summary

Many files. One package.

A ZIP file is an archive format that can package multiple files and folders into a single file. ZIP supports lossless compression, preserves directory structures and is widely used for transfers, backups, downloads and software packaging. Some formats such as XLSX, DOCX and PPTX also use ZIP internally as their container format.

What Is an .xlsx File?

// spreadsheets

What Is an .xlsx File?

An .xlsx file is a modern spreadsheet file format used by Microsoft Excel and many other spreadsheet programs. It can store worksheets, numbers, text, formulas, tables, charts, formatting and other structured spreadsheet data.

// definition

.xlsx is a spreadsheet file format

An .xlsx file is a spreadsheet workbook stored using Microsoft's Office Open XML spreadsheet format.

It is commonly associated with Microsoft Excel, although other spreadsheet applications can also read and write .xlsx files.

A single workbook can contain multiple worksheets along with formulas, formatting, charts and other spreadsheet information.

// file extension

What does .xlsx mean?

The .xlsx extension identifies an Excel workbook stored using the Office Open XML format.

budget.xlsx customers.xlsx sales-data.xlsx project-tracker.xlsx

The extension tells software what kind of file it is dealing with and which format should be used to interpret the contents.

// workbook

An .xlsx file is a workbook

A workbook can contain one or more worksheets.

sales.xlsx │ ├── January ├── February ├── March └── Summary

Each worksheet contains a grid of rows and columns.

// cells

Spreadsheet data is stored in cells

Each cell is identified by a column and row.

A1 B1 C1 A2 B2 C2

For example:

A B C
Product Quantity Price
Keyboard 2 39.99
Mouse 4 19.50
// cell values

Cells can contain different kinds of information

Text Numbers Dates Times Formulas Booleans Errors
// formulas

.xlsx files can store formulas

A spreadsheet cell does not have to contain only a fixed value.

It can contain a formula:

=A1+B1

or:

=SUM(B2:B20)

The spreadsheet application evaluates the formula and displays the calculated result.

// formula + value

A formula and its displayed result are different things

Suppose a cell contains:

=10+20

The displayed result may be:

30

The workbook can retain the formula rather than simply replacing it with the number 30.

// formatting

.xlsx files can store presentation information

Unlike a simple CSV file, an .xlsx workbook can retain substantial visual formatting.

Fonts Colours Borders Alignment Number Formats Column Widths Row Heights Conditional Formatting
// workbook features

A workbook can contain much more than cells

Worksheets

Multiple spreadsheet pages can exist inside one file.

Charts

Data can be visualised using charts and graphs.

Tables

Structured Excel tables can organise related records.

Formulas

Calculations can reference other cells and sheets.

Validation

Rules can restrict what users are allowed to enter.

Hyperlinks

Cells can contain links to websites and other resources.

// office open xml

An .xlsx file is based on XML

The modern Excel workbook format belongs to the Office Open XML family of file formats.

Internally, workbook information is divided across a collection of structured XML files and related resources.

Workbook ↓ XML documents + relationships + styles + other resources
// zip container

An .xlsx file is also a ZIP package

One of the most interesting facts about .xlsx files is that they are packaged using ZIP compression.

If a copy of an .xlsx file is renamed from:

workbook.xlsx

to:

workbook.zip

ZIP-compatible software can usually open the package and reveal the internal files.

An .xlsx file is not one giant XML document. It is a ZIP package containing multiple XML documents and supporting files organised according to the Office Open XML format.

// internal structure

What is inside an .xlsx file?

A simplified workbook package might contain:

workbook.xlsx │ ├── [Content_Types].xml ├── _rels/ │ ├── docProps/ │ └── xl/ │ ├── workbook.xml ├── styles.xml ├── sharedStrings.xml ├── worksheets/ │ ├── sheet1.xml │ └── sheet2.xml │ └── _rels/

The exact contents depend on which features are used in the workbook.

// worksheet xml

Worksheets are represented using XML

Internally, a worksheet may contain XML structures representing rows and cells.

<row r="1"> <c r="A1"> ... </c> </row>

Spreadsheet software interprets these structures and presents them as the familiar grid seen in Excel.

// shared strings

Text may be stored separately from worksheet cells

Some .xlsx workbooks use a shared strings table.

Instead of repeating the same text many times inside worksheets, cells can reference entries stored in a shared XML structure.

Cell ↓ String reference ↓ sharedStrings.xml ↓ "Freelance Coder"
// styles

Formatting can be stored separately

Workbook styles can be defined in internal style information and referenced by cells.

This avoids having to repeat complete formatting instructions for every individual cell.

// xlsx vs xls

.xlsx replaced the older .xls format

.xls .xlsx
Older Excel format Modern Excel workbook format
Binary file format Office Open XML package
Associated with older Excel versions Introduced with Excel 2007
Legacy format Common modern format
// xlsx vs csv

.xlsx and .csv are very different

CSV XLSX
Plain-text format ZIP-based spreadsheet package
Usually represents one table Can contain multiple worksheets
No native cell formatting Supports extensive formatting
No native charts Can contain charts
Simple data exchange Complete spreadsheet workbook
// important distinction

Saving Excel data as CSV can remove workbook features

Suppose an .xlsx workbook contains:

3 worksheets formulas colours charts cell formatting

Exporting one sheet to CSV normally preserves the tabular values but not the complete workbook structure.

XLSX → full spreadsheet workbook CSV → plain tabular data
// macros

.xlsx files do not normally contain VBA macros

Excel uses a different extension for macro-enabled workbooks:

.xlsm
Extension Workbook type
.xlsx Standard Excel workbook
.xlsm Macro-enabled Excel workbook

This distinction matters. If a workbook depends on VBA macros, saving it as an ordinary .xlsx file is not the appropriate format for retaining those macros.

// programming

.xlsx files can be created by software

Excel itself is not required to generate every .xlsx workbook.

Programming libraries can create, read and modify spreadsheet files automatically.

Python JavaScript PHP Java C# Automation
// python example

Python can create .xlsx files

For example, libraries such as openpyxl can work with Excel workbooks.

from openpyxl import Workbook workbook = Workbook() sheet = workbook.active sheet["A1"] = "Product" sheet["B1"] = "Price" sheet["A2"] = "Keyboard" sheet["B2"] = 39.99 workbook.save("products.xlsx")

Software can therefore generate spreadsheets from databases, APIs and other data sources.

// automation

Spreadsheet generation can be automated

API ↓ Application ↓ Process data ↓ Generate .xlsx ↓ Spreadsheet report

This is useful for reporting, financial data, exports, project tracking and business workflows.

// compatibility

.xlsx files are supported by many applications

Microsoft Excel is the application most strongly associated with .xlsx, but other spreadsheet software can also work with the format.

Microsoft Excel Google Sheets LibreOffice Calc Spreadsheet Libraries

Complex workbook features may not always behave identically when the same file is opened in different spreadsheet applications.

// not plain text

An .xlsx file is not a plain-text file

Although its internal structure contains XML documents, the .xlsx file itself is a compressed package.

Opening it directly in a basic text editor will therefore not display the workbook in the same clean way as opening a CSV, TXT or XML file.

TXT → plain text CSV → plain text XML → plain text XLSX → compressed package containing XML and other resources
// uses

What are .xlsx files used for?

Budgets Accounts Data Analysis Reports Project Tracking Invoices Customer Lists Dashboards Financial Models Data Exports
// mental model

The simplest way to think about .xlsx

.xlsx file ↓ ZIP package ↓ XML + relationships + resources ↓ Workbook ↓ Worksheets ↓ Rows + columns + cells ↓ Values + formulas + formatting
// summary

More than just a table.

An .xlsx file is a modern spreadsheet workbook format based on Office Open XML. It can contain multiple worksheets, values, formulas, formatting, charts and other spreadsheet features. Internally, the workbook is stored as a ZIP package containing XML documents and related resources.

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 an IP Address?

// networking What Is an IP Address? An IP address is a numerical address used t...