What Is an API?
An API, or application programming interface, is a defined set of rules that lets one software program request services or data from another. It states the requests a program can make, the data formats to use, and the responses it gets back, while hiding the internal workings of the service behind a stable interface. Roy Fielding defined the REST architectural style behind most web APIs in his 2000 doctoral dissertation.
What Is an API?
An API is a defined interface that lets one program request data or services from another using a fixed set of rules and formats. It describes what requests are valid and what responses follow, without exposing how the receiving program works inside. An API provides three core things:
- A contract: the available operations, the required inputs, and the structure of the response, which both programs agree to follow.
- Abstraction: the internal implementation stays hidden, so a program uses a service without knowing how it stores or processes data.
- Interoperability: programs written in different languages, on different machines, exchange data through the shared interface.
Best put: an API is a doorway between programs – send a request in the agreed format, get a response back. The guide to programming languages covers the languages that call APIs, and the overview of the internet covers the network web APIs travel across.
How Do APIs Work?
APIs work through a request-and-response cycle: a client sends a structured request to a defined endpoint, and the server returns a structured response. The request states the operation; the response carries the data or a status result. The cycle has four core parts:
- The endpoint is the address the request goes to, identifying the resource or operation the API exposes.
- The request carries a method, parameters, and sometimes a body that tells the server what data or action the client wants.
- The response returns the requested data, usually as JSON, with a status code that reports success or failure.
- The status code reports the outcome – 200 for success, 404 for a missing resource – following HTTP conventions.
A single API call flows through three stages from app to server and back:
- Request. The client app calls an endpoint with an HTTP method (GET to read, POST to send) and any parameters or JSON body.
- Server. The server authenticates the caller, runs the operation, and gathers or changes the data behind the interface.
- Response. The server returns a status code plus a body – usually JSON – that the app reads and turns into a result on screen.
Best put: a web API reads data with GET and sends data with POST, then answers with a code and a body. The explanation of how data travels on the internet covers the network path that request and response follow. JSON is the common format because it is compact and readable by programs in any language.
What Are the Types of API?
APIs fall into several types – web, library, operating system, and hardware APIs – each exposing a different kind of service to programs. The type depends on what it connects and where it runs. The main types are:
- Web APIs let programs communicate over a network using HTTP, returning data from remote servers, as REST and GraphQL APIs do.
- Library APIs expose the functions of a code library, defining how to call them from source code.
- Operating system APIs let programs request services from the OS, such as reading files or allocating memory.
- Hardware APIs let software talk to devices through drivers – printers, graphics cards, and sensors.
Best for the internet: web APIs dominate because they connect applications across the network, while library and OS APIs work within a single machine. The overview of software frameworks shows how frameworks expose library APIs that developers call. Each type applies the same idea of a fixed interface to a different software layer.
What Is the Difference Between REST, SOAP, and GraphQL?
REST, SOAP, and GraphQL are three styles of web API: REST uses HTTP and resources, SOAP uses strict XML messaging, and GraphQL lets clients request exactly the data they need. The style shapes how a client asks for and receives data. The three differ as below:

REST
SOAP
GraphQL
Best fit: REST suits most public web APIs because it maps cleanly to HTTP and resources; GraphQL suits apps needing precise, flexible queries; SOAP holds on where formal messaging contracts are required. The guide to how the internet works explains the HTTP foundation REST and GraphQL both build on.
How Does API Authentication Work?
API authentication verifies which program is making a request, using methods such as API keys, OAuth tokens, and JSON Web Tokens to control access. It stops unauthorized programs from using a service or reading its data. The main methods are:

- API keys are unique strings a client sends with each request, identifying the calling application to the server.
- OAuth issues access tokens, letting a user grant an app limited access without sharing a password – the basis of “sign in with Google”.
- JSON Web Tokens are signed tokens carrying identity and permissions, which the server verifies on each request without storing session state.
- Basic authentication sends a username and password with each request, used over encrypted connections for simple internal APIs.
Best for user access: OAuth is the standard for letting an app reach a user’s data on another service, while API keys identify the app, not the person. The explanation of how data travels on the internet covers the encrypted HTTPS connections that protect these credentials in transit.
What Are Real-World Examples of APIs?
Real-world APIs include weather services, payment processors, and mapping platforms, each letting an app add a feature without building the underlying service. Most modern apps combine several external APIs. Common examples:
Weather
Payments (Stripe)
Maps
Log in with Google
Best illustration: one mobile app may call a maps API for navigation, a payment API for checkout, and a weather API for forecasts – services it never builds itself. That reuse is why APIs underpin modern software. The software framework guide shows how frameworks simplify calling these external APIs from application code.
What Is the Difference Between an API and a Web Service?
A web service is a type of API that communicates over a network using web protocols, while an API is the broader concept covering any defined interface between programs, networked or local. Every web service is an API, but not every API is a web service. They differ as below:
- Scope: an API covers any interface between software components; a web service specifically communicates over a network.
- Transport: a web service always uses web protocols such as HTTP, while an API may run entirely within one machine.
- Data formats: web services send XML or JSON across the network; a local library API passes data structures directly in memory.
- Examples: a REST web service is an API, but a library API that runs in-process is not a web service.
Best summary: a web service is the networked subset of the wider API concept, while local APIs (operating system and library) need no network and run within a single program. The guide to how the internet works explains the network layer every web service depends on but a local API does not.
API Styles Comparison Table
The table compares the three main web API styles – REST, SOAP, and GraphQL – across protocol, data format, flexibility, and typical use, summarizing how each handles communication between programs:
| Aspect | REST | SOAP | GraphQL |
|---|---|---|---|
| Type | Architectural style | Protocol | Query language and runtime |
| Data format | Usually JSON | XML only | JSON |
| Transport | HTTP | HTTP, SMTP, others | HTTP |
| Data fetching | Fixed endpoints per resource | Operations defined in WSDL | Client requests exact fields |
| Defined by | Roy Fielding, 2000 | W3C standard | Facebook, 2015 |
| Common use | Public web APIs | Enterprise and finance | Flexible client-driven apps |
Last Thoughts on APIs
An API is the defined interface that lets programs communicate – sending structured requests to endpoints and receiving structured responses without exposing internal code. Web APIs built on REST, SOAP, and GraphQL connect applications across the internet, while library and operating system APIs work within a machine.
Authentication protects access, and real-world weather, payment, and maps APIs let apps reuse services they never build. Readers can continue with the guide to programming languages, the overview of how the internet works, or the software applications guide that links the full software cluster.
Key Takeaways:
- An API is a defined interface that lets one program request data or services from another using fixed rules and formats.
- APIs work through requests and responses, where a client sends a structured request to an endpoint and the server returns a response.
- API types include web, library, operating system, and hardware APIs, each exposing a different kind of service.
- REST, SOAP, and GraphQL are web API styles, with REST the most common, SOAP strict XML, and GraphQL client-driven.
- Authentication controls access through API keys, OAuth, and JSON Web Tokens that verify the calling program or user.
- Real-world APIs include weather, payment, and maps services that apps combine without building the underlying systems.
Frequently Asked Questions (FAQs)
What is an API in simple terms?
An API, or application programming interface, is a set of rules that lets one program request data or services from another. It defines the valid requests and the responses without exposing internal code.
How does an API work?
An API works through a request and response cycle. A client sends a structured request to a defined endpoint, and the server returns a response with data and a status code, usually formatted as JSON.
What is the difference between REST and SOAP?
REST is an architectural style that uses HTTP methods and resource URLs, usually returning JSON. SOAP is a protocol that exchanges strict XML messages, used in enterprise systems needing formal contracts.
What is a REST API?
A REST API is a web API following the REST style defined by Roy Fielding in 2000. It uses HTTP methods like GET and POST against resource URLs and typically returns data in JSON format.
What is API authentication?
API authentication verifies which program or user is making a request. Common methods include API keys, OAuth tokens, and JSON Web Tokens, which control access and prevent unauthorized use of the API.
What are examples of APIs?
Common APIs include weather services, payment processors such as Stripe and PayPal, and mapping platforms such as Google Maps. Apps combine these APIs to add features without building the underlying services.


