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.
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.
An API is a controlled interface
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.
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.
The website can then display the information returned by the API.
Many APIs use requests and responses
A client sends a request.
The API processes the request and sends a response.
This request-response model is extremely common in web APIs.
Web APIs communicate over networks
Many modern APIs are accessed using HTTP or HTTPS, the same fundamental protocols used by websites.
Software can send an HTTP request to this address and receive structured information in return.
What is an API endpoint?
An endpoint is a particular location exposed by an API for performing an operation or accessing a resource.
Different endpoints can provide access to different types of information or functionality.
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 can retrieve information
The API might return:
POST can send information
A client might create a new customer by sending:
with data such as:
The server can validate the information, store it and return a response.
APIs commonly use JSON
JSON is a convenient format for exchanging structured information between software systems.
A client can parse this data and use the individual values in its own application.
APIs do not have to use JSON
Depending on the system, an API may exchange data using:
Requests can include parameters
Parameters allow the client to specify what it wants.
Here:
provides additional information to the API.
HTTP requests can contain headers
Headers carry metadata about a request or response.
Headers can specify things such as data format, authentication information and caching behaviour.
Many APIs require authentication
An API may need to know which application or user is making a request.
Common approaches include:
API credentials should be protected. Private keys and tokens should not normally be exposed publicly in website source code or public repositories.
What is an API key?
An API key is a value that can identify an application or account when making API requests.
The service can use the key to determine who is making the request and which permissions or usage limits apply.
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 can call web APIs
The browser sends the request, receives the response and converts the JSON into JavaScript data.
Server-side software can also use APIs
PHP, Python, JavaScript, Java, C# and many other languages can communicate with APIs.
APIs allow systems written in completely different programming languages to work together.
An API can sit between an application and a 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.
APIs can control what software is allowed to do
An application may be allowed to:
while being prevented from directly accessing internal systems or performing unauthorised operations.
APIs can limit how frequently they are used
A service might allow:
or:
These restrictions are called rate limits.
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.
APIs can use different technologies
The best approach depends on the systems involved and what they need to communicate.
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.
In each case, the API defines how another piece of software can interact with the system.
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.
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.
APIs make automation possible
Suppose a customer submits an online order.
Multiple systems can communicate automatically without someone manually copying the information between them.
An API behaves like a software contract
The API documentation defines how another program is expected to interact with the system.
It might specify:
As long as both systems follow the agreed interface, their internal implementations can often change without requiring the other system to understand those details.
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.
The simplest way to think about an API
The API defines the rules for that conversation.
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.