What is an API? API stands for Application Programming Interface. It is a defined way for one piece of software to use functions or information provided by another. Instead of a person opening a screen and clicking buttons, a program follows an agreed interface: it asks for a particular operation or piece of data and receives a response. An API may be local to a program, built into a device or browser, or made available across a network.
Here is the useful everyday picture. A weather app can show a forecast without collecting weather measurements itself. It may request forecast data from a separate service using that service’s API. The service applies its rules and returns information the app can display. The API is the contract for this interaction; it is not necessarily the database, the application screen or the Internet connection.
Quick notes: API = interface between software components. A client makes a request; a service or library performs an allowed operation; a result or error comes back. The contract specifies available actions, required inputs, output format and limits. Web APIs commonly use HTTP, URLs and JSON, but not all APIs are web APIs. A successful connection does not guarantee trustworthy data, permission to use it or a correct final answer.
Why APIs exist: the problem they solve
Imagine every school website, banking app, map service and delivery platform had to contain its own complete mapping system, payment network, messaging service and identity provider. Many developers would spend their time rebuilding the same foundational functions. APIs help separate responsibilities. One system can specialise in providing a service while another system specialises in presenting that service to a user.
An API works like the door to a well-defined workshop. You do not need access to every machine inside. You need to know what requests the workshop accepts, the safety rules, what inputs are required and what results it promises. This analogy is useful, but remember that software APIs can also be interfaces inside a single application, not only over the Internet.
The hidden lesson is about boundaries. Good software does not let any connected program change anything it wants. The interface defines what may be requested and how the system reports success, failure or missing data.
How an API works step by step
- Identify a need: a timetable app needs an updated bus arrival estimate, or a school dashboard needs a count of library books.
- Choose the documented operation: the developer finds an endpoint or function that provides the needed result.
- Prepare the inputs: the request may include a bus-stop identifier, date, authentication token or other permitted parameters.
- Send or invoke the request: a networked web API often uses an HTTP request; a local library API may use a function call.
- Validate and process: the service checks permissions and inputs, performs the defined operation and produces a result or error.
- Interpret the response: the calling software reads the returned data, validates it and decides what to display or do next.
Notice the final step. A reply is not automatically the outcome the user wanted. The answer might be incomplete, out of date, incorrectly interpreted or relevant to the wrong identifier. Reliable integration checks both the technical response and the real-world purpose.
A worked example: a fictional library catalogue API
A student builds a simple app that shows whether a library book is available. To teach the structure without exposing any real service or credentials, imagine a fictional endpoint https://api.example.edu/books/42. The number 42 is an invented book identifier.
GET /books/42 HTTP/1.1
Host: api.example.edu
Accept: application/json
The fictional service might reply with a successful status and a JSON body. JSON is a text format used to represent values such as strings, numbers, true/false flags and collections.
HTTP/1.1 200 OK
Content-Type: application/json
{
"book_id": 42,
"title": "A Student's Guide to Thinking",
"available": true,
"copies": 2
}
The app can display ‘Two copies available’ only after reading available and copies correctly. It should not guess from the title. If the book identifier does not exist, the API might return 404 Not Found. If a request lacks permission, it might return 403 Forbidden. If the server has a temporary fault, it might return a 5xx error. The contract and documentation—not the programmer’s wishes—determine what each response means.
This example is invented for learning. It is not a real library endpoint, a working API key or a promise that every service uses this response structure.
API versus website: the difference readers often miss
A website is normally designed for humans to view and interact with. An API is designed for software to call. They may expose information from the same organisation, but they serve different audiences. For example, you can read a public transport webpage in a browser, while a separate application may fetch transport data through a documented API and present it in its own layout.
Some APIs operate behind familiar browser actions. Selecting a date in a calendar may cause the page’s JavaScript to request availability from a service. You see the result, not necessarily the request. Conversely, a library API may expose functions to a program without involving any server at all. Therefore ‘API’ and ‘web API’ should not be treated as exact synonyms.
The four things every API contract must clarify
1. The operations that are allowed
A service may support reading a record, creating an item, changing an item or deleting an item. In many HTTP-based systems, these correspond to operations commonly expressed using GET, POST, PATCH or DELETE, although real designs vary. The existence of a URL alone does not grant permission to alter data.
2. The shape and meaning of inputs
The contract might require an identifier, time interval, language code or measurement unit. If a service expects distance in metres and your app supplies kilometres, the request may be syntactically accepted while the result is dangerously wrong. Good developers read definitions rather than merely copying examples.
3. The shape and meaning of outputs
A value of 0 might mean zero events, no result, an unknown reading or a missing code depending on the documentation. Distinguishing null, an empty list, zero and a failed request is a data-literacy skill, not a cosmetic programming preference.
4. Permissions, quotas and failure behaviour
Some APIs are open; others require authentication, a paid account, a private key or a specific role. Services may limit request frequency, file size or available history. Developers should understand retries, timeouts, rate limits, service interruptions and version changes.
What is an API endpoint?
In a web API, an endpoint is a particular address or path through which a defined operation can be requested. You may see endpoints described with a method and path together, such as GET /students/42. The path is not a complete description by itself: valid parameters, permissions, return values and error states matter too.
An endpoint is not automatically a database table. A carefully designed service may calculate a result, combine several datasets or return a filtered view. Exposing a direct route to sensitive information without proper authorisation would be a design failure.
What is an API key—and what can go wrong?
An API key is a credential that can identify or authorise a caller in some systems. Keys have different security meanings depending on the service; do not assume an API key alone gives robust user-level authentication. Treat secret keys as secrets, follow the provider’s guidance and do not paste them into a public website, video, student worksheet or shared repository.
For a classroom demonstration, use a fictional key such as DEMO_KEY_NOT_REAL. Never demonstrate real account secrets in a screenshot. The safe exercise is understanding the request contract and response, not acquiring access to somebody else’s system.
API, authentication and authorisation
Authentication asks who a caller is. Authorisation asks what that caller may do. These are related but separate. A school administrator might be recognised by a system yet still be prohibited from reading a student’s confidential medical record. A valid login cannot override the principle of least privilege.
Many services also need auditing, rate limits, input validation, secure transport and clear responsibility for personal information. An API design that returns a ‘successful’ response while leaking private records is not a successful system.
Why API requests fail: a practical diagnostic
- 400 Bad Request: the request is malformed or invalid for the service’s rules.
- 401 Unauthorized: authentication is missing or invalid under the API’s scheme.
- 403 Forbidden: the caller does not have permission for the requested resource or operation.
- 404 Not Found: the requested endpoint or resource is not found, or the service deliberately hides its existence.
- 429 Too Many Requests: the service is enforcing a rate limit.
- 500-series errors: the service or an upstream component cannot complete the operation.
The exact meaning depends on the API’s documentation. A status of 200 does not prove the returned record is recent, correctly interpreted or complete. A developer must check the data contract, not just the network status.
Three examples that make APIs useful
School: connecting a learning platform to a timetable
A student portal might obtain timetable information from an authorised school service rather than keeping several manually updated copies. The benefit is consistent information, but it depends on accurate identifiers, permission checks and timely updates. A student should not have to learn internal API syntax just to view the timetable.
Transport: showing arrivals in a travel app
A public transit app can request location-specific information from a data provider. The interface might provide estimated arrivals or service information. The student should distinguish a scheduled time from a prediction, and a prediction from a guarantee. The data provider’s publication limits and timestamps matter.
Research: using a public dataset repeatedly
A researcher may download many months of structured data through an official data API. They must record the variable definitions, observation dates and changes in the data source. An easy connection to a dataset is not proof that two years of data are directly comparable.
For a deeper lesson on why datasets can remain hard to use even after publication, see How Public Data Portals Fail. It focuses on data definitions, reliability and responsible reuse rather than general API vocabulary.
APIs in Python: a beginner-friendly mental model
Python includes many interfaces within its standard library. The familiar call len(['a', 'b']) uses a documented function interface to ask for the length of a collection. It is an API interaction even though no website is contacted. This is a helpful first step before learning more complex web requests.
books = ["Biology", "Mathematics", "History"]
count = len(books)
print(count) # 3
The program supplies one input—a list—and receives one result—the number of items. The caller does not have to know every internal detail of how Python obtains the length. It only needs to understand the supported interface and valid input types.
A separate web-API tutorial might use a Python HTTP library to send requests. Beginners should start with documentation and publicly accessible sample data; they should never place payment credentials, school accounts or real private student data into online snippets.
How to read API documentation quickly and correctly
- Start with purpose: What problem does the service solve, and what does it not solve?
- Find the exact operation: Identify the documented method, endpoint or library function.
- List mandatory inputs: Names, data types, units, allowed ranges, identity and permissions.
- Read the output schema: Know which fields may be missing, empty or changed.
- Inspect errors and limits: Decide how to handle failures, timeouts and rate limits.
- Run a harmless test: Use a sandbox or fictional input; compare the result with your expectation.
- Record evidence: Preserve documentation versions, timestamps and relevant source definitions.
This method is useful even for people who never become programmers. Product managers, teachers, researchers and journalists can ask better questions when they know that ‘the app connected’ and ‘the information is correct’ are two different claims.
The five API misconceptions to repair
- ‘An API is a website.’ Some APIs are web-based; others are local interfaces inside software.
- ‘Every API gives free access to all data.’ Permissions, licensing, fees, quotas and privacy rules differ.
- ‘A response of 200 means the answer must be correct.’ Technical success is separate from truth and relevance.
- ‘I can guess how a field is defined.’ A field’s units, null meaning and refresh interval must be documented.
- ‘AI can write an API call, so the call must be valid.’ Generated syntax, permissions, outcomes and claimed results require verification.
A 20-minute practice activity for students
Draw two boxes labelled ‘Library App’ and ‘Library Service’. Draw an arrow from the app to the service labelled ‘Request book 42’. Draw the return arrow labelled ‘Available: true; copies: 2’. Now change the book number to an invented missing identifier. What should the app display? What if the service is temporarily unavailable? What should happen if the student is not allowed to see a particular record?
This exercise teaches interfaces, permissions, response interpretation and graceful failure without requiring real network access. To extend it, write the contract in four lines: purpose, input, output, and error.
How to learn APIs over seven days
- Day 1: Explain what API stands for, using a software-to-software example.
- Day 2: Distinguish a user interface from an API.
- Day 3: Draw a request-response diagram.
- Day 4: Read a fictional JSON response and identify the data types.
- Day 5: Compare success, missing-record and permission-denied outcomes.
- Day 6: Read a real public API’s documentation without sending credentials.
- Day 7: Explain how you would verify a result’s meaning and freshness.
Frequently asked questions about APIs
What is an API in simple words?
An API is a set of rules that lets one part of software use a service or function supplied by another part.
What does API stand for?
Application Programming Interface.
Does an API always use the Internet?
No. A programming-language library, an operating system and a browser can expose APIs locally. Web APIs are the networked subset.
What is the difference between API and database?
A database stores and organises data. An API is an interface that may provide controlled access to data or operations, sometimes using a database behind the scenes.
Are APIs safe?
They can be designed and operated securely, but security depends on authentication, authorisation, data handling, transport protection, monitoring and other controls. The label ‘API’ alone proves nothing about safety.
Can a beginner understand APIs without knowing code?
Yes. Start with inputs, operations, outputs and errors. Coding becomes easier when the purpose and contract are clear.
What is the difference between API and AI?
An API is an interface. Artificial intelligence describes systems or techniques that perform tasks involving capabilities such as pattern recognition or generation. AI services may offer APIs, but the terms are not interchangeable.
Where to go next
If you want to write your first small program, start with What is Python?. If you want to understand how software can be abused through fake login requests, visit What is Phishing?. For a specialist route about careful AI-assisted API work, read How to Work With APIs Using Super Intelligence.
Sources and definitions
Read the MDN API glossary, the MDN explanation of HTTP requests and responses and MDN’s HTTP status reference. The library endpoint and data shown here are fictional teaching examples. Real APIs differ in contract, security rules and update schedule.
